From e12df8a072c755db09101b611ab23e9235eb91fb Mon Sep 17 00:00:00 2001 From: Axel Christ Date: Tue, 20 Jun 2023 14:47:39 +0200 Subject: [PATCH] Rework onmetal-api-net * Switch to aggregated API * Add types handling * Network ID allocation * (Public) IP allocation * Network interface management * NAT Gateway management * Load balancer management * Load balancer instance management * Update apinetlet to align with latest onmetal-api changes * Implement metalnetlet correctly and align with new types * Update tests and testing infrastructure --- .github/workflows/lint.yml | 2 +- .golangci.yaml | 11 +- Makefile | 141 +- api/core/v1alpha1/common_types.go | 41 + api/core/v1alpha1/daemonset_types.go | 52 + api/core/v1alpha1/doc.go | 24 + api/core/v1alpha1/instance_types.go | 196 + api/core/v1alpha1/ip_types.go | 75 + api/core/v1alpha1/ipaddress_types.go | 59 + api/core/v1alpha1/loadbalancer_types.go | 114 + .../v1alpha1/loadbalancerrouting_types.go | 63 + api/core/v1alpha1/natgateway_types.go | 81 + .../v1alpha1/natgatewayautoscaler_types.go | 54 + api/core/v1alpha1/nattable_types.go | 70 + api/core/v1alpha1/network_types.go | 48 + api/core/v1alpha1/networkid_types.go | 57 + api/core/v1alpha1/networkinterface_types.go | 137 + api/core/v1alpha1/node_types.go | 47 + api/core/v1alpha1/register.go | 74 + api/core/v1alpha1/well_known_annotations.go | 17 + api/core/v1alpha1/well_known_labels.go | 22 + api/core/v1alpha1/zz_generated.deepcopy.go | 1806 ++ api/v1alpha1/network_types.go | 91 - api/v1alpha1/publicip_types.go | 102 - api/v1alpha1/zz_generated.deepcopy.go | 253 - .../api/net/net.go | 153 +- apimachinery/equality/semantic.go | 47 + apinetlet/api/v1alpha1/common_types.go | 29 +- .../events.go => apinetlet/client/client.go | 7 +- apinetlet/client/config/getter.go | 2 +- apinetlet/client/sourceaware.go | 58 + .../controllers/controllers_suite_test.go | 97 +- apinetlet/controllers/conversion.go | 82 + apinetlet/controllers/helper.go | 52 +- apinetlet/controllers/helper_test.go | 54 + .../controllers/loadbalancer_controller.go | 312 +- .../loadbalancer_controller_test.go | 186 +- .../controllers/natgateway_controller.go | 236 +- .../controllers/natgateway_controller_test.go | 167 +- apinetlet/controllers/network_controller.go | 144 +- .../controllers/network_controller_test.go | 107 +- .../networkinterface_controller.go | 575 + .../networkinterface_controller_test.go | 106 + apinetlet/controllers/virtualip_controller.go | 138 +- .../controllers/virtualip_controller_test.go | 82 +- apinetlet/handler/sourceaware.go | 26 + apinetlet/provider/provider.go | 97 + apinetlet/provider/provider_suite_test.go | 27 + apinetlet/provider/provider_test.go | 52 + .../core/v1alpha1/affinity.go | 47 + .../core/v1alpha1/daemonset.go | 257 + .../core/v1alpha1/daemonsetspec.go | 51 + .../core/v1alpha1/daemonsetstatus.go | 38 + .../core/v1alpha1/instance.go | 257 + .../core/v1alpha1/instanceaffinityterm.go | 51 + .../core/v1alpha1/instanceantiaffinity.go | 43 + .../core/v1alpha1/instancespec.go | 119 + .../core/v1alpha1/instancestatus.go | 53 + .../core/v1alpha1/instancetemplate.go | 187 + .../applyconfigurations/core/v1alpha1/ip.go | 257 + .../core/v1alpha1/ipaddress.go | 246 + .../core/v1alpha1/ipaddressclaimref.go | 78 + .../core/v1alpha1/ipaddressspec.go | 51 + .../core/v1alpha1/ipclaimref.go | 69 + .../core/v1alpha1/ipspec.go | 71 + .../core/v1alpha1/loadbalancer.go | 257 + .../core/v1alpha1/loadbalancerdestination.go | 51 + .../core/v1alpha1/loadbalancerip.go | 61 + .../core/v1alpha1/loadbalancerport.go | 60 + .../core/v1alpha1/loadbalancerrouting.go | 265 + .../core/v1alpha1/loadbalancerspec.go | 99 + .../core/v1alpha1/loadbalancerstatus.go | 53 + .../core/v1alpha1/loadbalancertargetref.go | 61 + .../core/v1alpha1/natgateway.go | 257 + .../core/v1alpha1/natgatewayautoscaler.go | 257 + .../core/v1alpha1/natgatewayautoscalerspec.go | 60 + .../core/v1alpha1/natgatewayip.go | 51 + .../core/v1alpha1/natgatewayspec.go | 74 + .../core/v1alpha1/natgatewaystatus.go | 47 + .../core/v1alpha1/natip.go | 56 + .../core/v1alpha1/natipsection.go | 69 + .../core/v1alpha1/nattable.go | 253 + .../core/v1alpha1/nattableiptargetref.go | 61 + .../core/v1alpha1/network.go | 257 + .../core/v1alpha1/networkid.go | 246 + .../core/v1alpha1/networkidclaimref.go | 78 + .../core/v1alpha1/networkidspec.go | 38 + .../core/v1alpha1/networkinterface.go | 257 + .../core/v1alpha1/networkinterfacenat.go | 51 + .../v1alpha1/networkinterfacenatclaimref.go | 51 + .../core/v1alpha1/networkinterfacepublicip.go | 61 + .../core/v1alpha1/networkinterfacespec.go | 102 + .../core/v1alpha1/networkinterfacestatus.go | 85 + .../core/v1alpha1/networkspec.go | 38 + .../applyconfigurations/core/v1alpha1/node.go | 255 + .../core/v1alpha1/nodeaffinity.go | 38 + .../core/v1alpha1/nodeselector.go | 43 + .../core/v1alpha1/nodeselectorrequirement.go | 62 + .../core/v1alpha1/nodeselectorterm.go | 57 + .../core/v1alpha1/pciaddress.go | 65 + .../core/v1alpha1/topologyspreadconstraint.go | 70 + .../applyconfigurations/internal/internal.go | 1135 + .../meta/v1/labelselector.go | 58 + .../meta/v1/labelselectorrequirement.go | 62 + .../meta/v1/managedfieldsentry.go | 96 + .../applyconfigurations/meta/v1/objectmeta.go | 170 + .../meta/v1/ownerreference.go | 87 + .../applyconfigurations/meta/v1/typemeta.go | 47 + client-go/applyconfigurations/utils.go | 154 + client-go/informers/core/interface.go | 45 + .../informers/core/v1alpha1/daemonset.go | 89 + client-go/informers/core/v1alpha1/instance.go | 89 + .../informers/core/v1alpha1/interface.go | 128 + client-go/informers/core/v1alpha1/ip.go | 89 + .../informers/core/v1alpha1/ipaddress.go | 88 + .../informers/core/v1alpha1/loadbalancer.go | 89 + .../core/v1alpha1/loadbalancerrouting.go | 89 + .../informers/core/v1alpha1/natgateway.go | 89 + .../core/v1alpha1/natgatewayautoscaler.go | 89 + client-go/informers/core/v1alpha1/nattable.go | 89 + client-go/informers/core/v1alpha1/network.go | 89 + .../informers/core/v1alpha1/networkid.go | 88 + .../core/v1alpha1/networkinterface.go | 89 + client-go/informers/core/v1alpha1/node.go | 88 + client-go/informers/factory.go | 250 + client-go/informers/generic.go | 85 + .../internalinterfaces/factory_interfaces.go | 39 + client-go/listers/core/v1alpha1/daemonset.go | 98 + .../core/v1alpha1/expansion_generated.go | 110 + client-go/listers/core/v1alpha1/instance.go | 98 + client-go/listers/core/v1alpha1/ip.go | 98 + client-go/listers/core/v1alpha1/ipaddress.go | 67 + .../listers/core/v1alpha1/loadbalancer.go | 98 + .../core/v1alpha1/loadbalancerrouting.go | 98 + client-go/listers/core/v1alpha1/natgateway.go | 98 + .../core/v1alpha1/natgatewayautoscaler.go | 98 + client-go/listers/core/v1alpha1/nattable.go | 98 + client-go/listers/core/v1alpha1/network.go | 98 + client-go/listers/core/v1alpha1/networkid.go | 67 + .../listers/core/v1alpha1/networkinterface.go | 98 + client-go/listers/core/v1alpha1/node.go | 67 + client-go/onmetalapinet/clientset.go | 119 + .../onmetalapinet/fake/clientset_generated.go | 84 + client-go/onmetalapinet/fake/doc.go | 19 + client-go/onmetalapinet/fake/register.go | 55 + client-go/onmetalapinet/scheme/doc.go | 19 + client-go/onmetalapinet/scheme/register.go | 55 + .../typed/core/v1alpha1/core_client.go | 166 + .../typed/core/v1alpha1/daemonset.go | 255 + .../onmetalapinet/typed/core/v1alpha1/doc.go | 19 + .../typed/core/v1alpha1/fake/doc.go | 19 + .../core/v1alpha1/fake/fake_core_client.go | 87 + .../core/v1alpha1/fake/fake_daemonset.go | 188 + .../typed/core/v1alpha1/fake/fake_instance.go | 188 + .../typed/core/v1alpha1/fake/fake_ip.go | 188 + .../core/v1alpha1/fake/fake_ipaddress.go | 144 + .../core/v1alpha1/fake/fake_loadbalancer.go | 188 + .../v1alpha1/fake/fake_loadbalancerrouting.go | 153 + .../core/v1alpha1/fake/fake_natgateway.go | 188 + .../fake/fake_natgatewayautoscaler.go | 188 + .../typed/core/v1alpha1/fake/fake_nattable.go | 153 + .../typed/core/v1alpha1/fake/fake_network.go | 188 + .../core/v1alpha1/fake/fake_networkid.go | 144 + .../v1alpha1/fake/fake_networkinterface.go | 188 + .../typed/core/v1alpha1/fake/fake_node.go | 177 + .../core/v1alpha1/generated_expansion.go | 44 + .../typed/core/v1alpha1/instance.go | 255 + .../onmetalapinet/typed/core/v1alpha1/ip.go | 255 + .../typed/core/v1alpha1/ipaddress.go | 196 + .../typed/core/v1alpha1/loadbalancer.go | 255 + .../core/v1alpha1/loadbalancerrouting.go | 207 + .../typed/core/v1alpha1/natgateway.go | 255 + .../core/v1alpha1/natgatewayautoscaler.go | 255 + .../typed/core/v1alpha1/nattable.go | 207 + .../typed/core/v1alpha1/network.go | 255 + .../typed/core/v1alpha1/networkid.go | 196 + .../typed/core/v1alpha1/networkinterface.go | 255 + .../onmetalapinet/typed/core/v1alpha1/node.go | 242 + client-go/openapi/api_violations.report | 199 + client-go/openapi/zz_generated.openapi.go | 17823 ++++++++++++++++ {apinetlet => cmd/apinetlet}/main.go | 43 +- cmd/apiserver/main.go | 31 + .../controller-manager}/main.go | 98 +- {metalnetlet => cmd/metalnetlet}/main.go | 46 +- config/apinetlet/apinet-rbac/role.yaml | 70 +- config/apinetlet/rbac/role.yaml | 52 +- .../apiservice/bases/kustomization.yaml | 5 + .../v1alpha1.core.apinet.api.onmetal.de.yaml | 12 + .../apiserver/apiservice/kustomization.yaml | 16 + .../apiserver/apiservice/kustomizeconfig.yaml | 11 + .../apiservice/patch-apiservice.yaml | 8 + config/apiserver/apiservice/service.yaml | 11 + config/apiserver/certmanager/certificate.yaml | 24 + .../apiserver/certmanager/kustomization.yaml | 5 + .../certmanager/kustomizeconfig.yaml | 16 + .../default/apiserver_certificate_patch.yaml | 28 + .../default/apiservicecainjection_patch.yaml | 8 + config/apiserver/default/kustomization.yaml | 102 + config/apiserver/etcd/etcd.yaml | 66 + config/apiserver/etcd/kustomization.yaml | 6 + config/apiserver/etcd/service.yaml | 11 + .../etcdless/apiserver_certificate_patch.yaml | 27 + .../etcdless/apiservicecainjection_patch.yaml | 8 + config/apiserver/etcdless/kustomization.yaml | 89 + config/apiserver/kind/kustomization.yaml | 8 + config/apiserver/kind/patch-apiserver.yaml | 11 + config/apiserver/rbac/apiserver_role.yaml | 37 + .../rbac/apiserver_role_binding.yaml | 25 + .../rbac/apiserver_service_account.yaml | 5 + .../rbac/bucketpool_bootstrapper_role.yaml | 20 + .../bucketpool_bootstrapper_rolebinding.yaml | 14 + .../rbac/bucketpool_role.yaml} | 72 +- .../rbac/bucketpool_rolebinding.yaml | 12 + config/apiserver/rbac/kustomization.yaml | 30 + .../rbac/machinepool_bootstrapper_role.yaml | 20 + .../machinepool_bootstrapper_rolebinding.yaml | 14 + config/apiserver/rbac/machinepool_role.yaml | 139 + .../rbac/machinepool_rolebinding.yaml | 12 + .../rbac/networkplugin_bootstrapper_role.yaml | 20 + ...etworkplugin_bootstrapper_rolebinding.yaml | 14 + config/apiserver/rbac/networkplugin_role.yaml | 140 + .../rbac/networkplugin_rolebinding.yaml | 12 + .../rbac/volumepool_bootstrapper_role.yaml | 20 + .../volumepool_bootstrapper_rolebinding.yaml | 14 + config/apiserver/rbac/volumepool_role.yaml | 91 + .../rbac/volumepool_rolebinding.yaml | 12 + config/apiserver/server/kustomization.yaml | 5 + config/apiserver/server/server.yaml | 69 + .../default/kustomization.yaml | 1 - .../default/manager_auth_proxy_patch.yaml | 0 .../default/manager_config_patch.yaml | 0 .../kind/add-manager-args.yaml | 0 .../kind/kustomization.yaml | 0 .../kind/patch-controller.yaml | 0 .../manager/controller_manager_config.yaml | 0 .../manager/kustomization.yaml | 0 .../manager/manager.yaml | 0 .../prometheus/kustomization.yaml | 0 .../prometheus/monitor.yaml | 0 .../rbac/apinetlet_bootstrapper_role.yaml | 0 .../apinetlet_bootstrapper_rolebinding.yaml | 0 config/controller/rbac/apinetlet_role.yaml | 95 + .../rbac/apinetlet_rolebinding.yaml | 0 .../rbac/auth_proxy_client_clusterrole.yaml | 0 .../rbac/auth_proxy_role.yaml | 0 .../rbac/auth_proxy_role_binding.yaml | 0 .../rbac/auth_proxy_service.yaml | 0 .../rbac/kustomization.yaml | 0 .../rbac/leader_election_role.yaml | 0 .../rbac/leader_election_role_binding.yaml | 0 .../rbac/metalnetlet_bootstrapper_role.yaml | 0 .../metalnetlet_bootstrapper_rolebinding.yaml | 0 config/controller/rbac/metalnetlet_role.yaml | 54 + .../rbac/metalnetlet_rolebinding.yaml | 0 config/controller/rbac/role.yaml | 190 + .../rbac/role_binding.yaml | 0 .../rbac/service_account.yaml | 0 config/default/apiserver/kustomization.yaml | 8 + .../default/apiserver/remove-namespace.yaml | 5 + config/default/controller/kustomization.yaml | 8 + .../default/controller/remove-namespace.yaml | 5 + config/default/kustomization.yaml | 7 + config/default/namespace.yaml | 6 + config/etcdless/apiserver/kustomization.yaml | 8 + .../etcdless/apiserver/remove-namespace.yaml | 5 + config/etcdless/controller/kustomization.yaml | 8 + .../etcdless/controller/remove-namespace.yaml | 5 + config/etcdless/kustomization.yaml | 7 + config/etcdless/namespace.yaml | 6 + config/metalnetlet/metalnet-rbac/role.yaml | 33 +- config/metalnetlet/rbac/role.yaml | 132 +- .../bases/apinet.api.onmetal.de_networks.yaml | 78 - .../apinet.api.onmetal.de_publicips.yaml | 83 - config/onmetal-api-net/crd/kustomization.yaml | 26 - .../onmetal-api-net/crd/kustomizeconfig.yaml | 19 - .../onmetal-api-net/rbac/apinetlet_role.yaml | 31 - .../rbac/metalnetlet_role.yaml | 19 - .../samples/apinet_v1alpha1_network.yaml | 4 - .../samples/apinet_v1alpha1_publicip.yaml | 6 - flag/flag.go | 6 +- go.mod | 79 +- go.sum | 190 +- hack/cluster-controller-gen.sh | 51 + hack/promote-let-role.sh | 12 + hack/types-to-internal-types.sh | 31 + hack/update-codegen.sh | 154 + internal/apis/core/common_types.go | 41 + internal/apis/core/daemonset_types.go | 52 + internal/apis/core/doc.go | 24 + internal/apis/core/install/install.go | 28 + internal/apis/core/instance_types.go | 196 + internal/apis/core/ip_types.go | 75 + internal/apis/core/ipaddress_types.go | 59 + internal/apis/core/loadbalancer_types.go | 114 + .../apis/core/loadbalancerrouting_types.go | 63 + internal/apis/core/natgateway_types.go | 81 + .../apis/core/natgatewayautoscaler_types.go | 54 + internal/apis/core/nattable_types.go | 70 + internal/apis/core/network_types.go | 48 + internal/apis/core/networkid_types.go | 57 + internal/apis/core/networkinterface_types.go | 137 + internal/apis/core/node_types.go | 47 + internal/apis/core/register.go | 72 + internal/apis/core/v1alpha1/conversions.go | 39 + internal/apis/core/v1alpha1/defaults.go | 30 + internal/apis/core/v1alpha1/doc.go | 23 + .../apis/core/v1alpha1/register.go | 26 +- .../core/v1alpha1/zz_generated.conversion.go | 2460 +++ .../core/v1alpha1/zz_generated.defaults.go | 46 + internal/apis/core/validation/daemonset.go | 46 + internal/apis/core/validation/instance.go | 46 + internal/apis/core/validation/ip.go | 46 + internal/apis/core/validation/ipaddress.go | 59 + internal/apis/core/validation/loadbalancer.go | 46 + .../core/validation/loadbalancerrouting.go | 38 + internal/apis/core/validation/natgateway.go | 46 + .../core/validation/natgatewayautoscaler.go | 46 + internal/apis/core/validation/nattable.go | 38 + internal/apis/core/validation/network.go | 46 + internal/apis/core/validation/networkid.go | 50 + .../apis/core/validation/networkinterface.go | 46 + internal/apis/core/validation/node.go | 46 + internal/apis/core/well_known_annotations.go | 17 + internal/apis/core/well_known_labels.go | 22 + internal/apis/core/zz_generated.deepcopy.go | 1806 ++ internal/apiserver/apiserver.go | 285 + internal/app/apiserver/apiserver.go | 179 + internal/app/app_suite_test.go | 109 + internal/app/core_test.go | 314 + internal/client/client.go | 139 + .../certificate/generic/certificate.go | 0 .../certificate/onmetal-api-net/apinetlet.go | 4 +- .../onmetal-api-net/metalnetlet.go | 4 +- .../onmetal-api-net/onmetalapinet.go | 2 +- .../certificateapproval_controller.go | 2 +- .../controllers/certificateapproval_test.go | 2 +- internal/controllers/common_test.go | 56 + .../controllers/controllers_suite_test.go | 179 + internal/controllers/daemonset_controller.go | 390 + .../controllers/daemonset_controller_test.go | 100 + internal/controllers/helper.go | 23 + .../controllers/ipaddressgc_controller.go | 162 + .../ipaddressgc_controller_test.go | 59 + .../controllers/loadbalancer_controller.go | 105 + .../loadbalancer_controller_test.go | 76 + internal/controllers/natgateway_controller.go | 460 + .../controllers/natgateway_controller_test.go | 90 + .../natgatewayautoscaler_controller.go | 191 + .../natgatewayautoscaler_controller_test.go | 62 + .../controllers/networkidgc_controller.go | 161 + internal/controllers/scheduler/cache.go | 443 + internal/controllers/scheduler_controller.go | 684 + .../controllers/scheduler_controller_test.go | 148 + internal/controllers/util.go | 125 + internal/natgateway/allocation.go | 96 + internal/natgateway/autoscaler.go | 91 + internal/nodeaffinity/nodeaffinity.go | 231 + internal/registry/daemonset/storage.go | 95 + internal/registry/daemonset/strategy.go | 132 + internal/registry/daemonset/tableconvertor.go | 67 + internal/registry/instance/storage.go | 95 + internal/registry/instance/strategy.go | 132 + internal/registry/instance/tableconvertor.go | 67 + .../ipaddressallocator/ipaddressallocator.go | 267 + internal/registry/ip/storage.go | 154 + internal/registry/ip/strategy.go | 122 + internal/registry/ip/tableconvertor.go | 67 + internal/registry/ipaddress/storage.go | 61 + internal/registry/ipaddress/strategy.go | 99 + internal/registry/ipaddress/tableconvertor.go | 67 + internal/registry/ipallocator/allocators.go | 309 + internal/registry/ipallocator/ipallocator.go | 303 + internal/registry/loadbalancer/storage.go | 207 + internal/registry/loadbalancer/strategy.go | 132 + .../registry/loadbalancer/tableconvertor.go | 67 + .../registry/loadbalancerrouting/storage.go | 88 + .../registry/loadbalancerrouting/strategy.go | 99 + .../loadbalancerrouting/tableconvertor.go | 67 + internal/registry/natgateway/storage.go | 195 + internal/registry/natgateway/strategy.go | 132 + .../registry/natgateway/tableconvertor.go | 67 + .../registry/natgatewayautoscaler/storage.go | 95 + .../registry/natgatewayautoscaler/strategy.go | 132 + .../natgatewayautoscaler/tableconvertor.go | 67 + internal/registry/nattable/storage.go | 61 + internal/registry/nattable/strategy.go | 99 + internal/registry/nattable/tableconvertor.go | 67 + .../networkidallocator/networkidallocator.go | 250 + internal/registry/network/storage.go | 156 + internal/registry/network/strategy.go | 132 + internal/registry/network/tableconvertor.go | 67 + internal/registry/networkid/storage.go | 61 + internal/registry/networkid/strategy.go | 99 + internal/registry/networkid/tableconvertor.go | 67 + internal/registry/networkinterface/storage.go | 195 + .../registry/networkinterface/strategy.go | 132 + .../networkinterface/tableconvertor.go | 67 + internal/registry/node/storage.go | 95 + internal/registry/node/strategy.go | 132 + internal/registry/node/tableconvertor.go | 67 + metalnetlet/client/client.go | 60 + metalnetlet/client/config/getter.go | 2 +- metalnetlet/client/sourceaware.go | 58 + metalnetlet/controllers/common.go | 81 + .../controllers/controllers_suite_test.go | 143 +- metalnetlet/controllers/conversion.go | 129 + .../controllers/instance_controller.go | 348 + .../controllers/instance_controller_test.go | 66 + .../controllers/metalnetnode_controller.go | 206 + .../metalnetnode_controller_test.go | 51 + metalnetlet/controllers/network_controller.go | 113 +- .../controllers/network_controller_test.go | 49 +- .../networkinterface_controller.go | 504 + .../networkinterface_controller_test.go | 84 + .../testdata/metalnet-crds/network.yaml | 67 - metalnetlet/handler/sourceaware.go | 26 + models-schema/main.go | 97 + models-schema/main.go.tmpl | 75 + networkid/networkid.go | 38 + .../controllers/controllers_suite_test.go | 166 - .../controllers/network_controller.go | 396 - .../controllers/network_controller_test.go | 119 - .../controllers/publicip_controller.go | 441 - .../controllers/publicip_controller_test.go | 124 - onmetal-api-net/controllers/util.go | 82 - utils/api/sourceaware.go | 44 + utils/cache/util.go | 63 + utils/client/sourceaware.go | 275 + utils/container/bimap.go | 111 + utils/container/rmap.go | 139 + utils/container/slots.go | 121 + utils/controller/refmanager.go | 146 + apiutils/apiutils.go => utils/core/core.go | 19 +- utils/expectations/expectations.go | 208 + utils/generic/generic.go | 30 + utils/handler/expectations.go | 143 + utils/handler/sourceaware.go | 167 + utils/hash/hash.go | 41 + utils/iterator/iterator.go | 99 + utils/netip/netip.go | 44 + utils/slots/slots.go | 186 + utils/testing/testing.go | 132 + 442 files changed, 62529 insertions(+), 3501 deletions(-) create mode 100644 api/core/v1alpha1/common_types.go create mode 100644 api/core/v1alpha1/daemonset_types.go create mode 100644 api/core/v1alpha1/doc.go create mode 100644 api/core/v1alpha1/instance_types.go create mode 100644 api/core/v1alpha1/ip_types.go create mode 100644 api/core/v1alpha1/ipaddress_types.go create mode 100644 api/core/v1alpha1/loadbalancer_types.go create mode 100644 api/core/v1alpha1/loadbalancerrouting_types.go create mode 100644 api/core/v1alpha1/natgateway_types.go create mode 100644 api/core/v1alpha1/natgatewayautoscaler_types.go create mode 100644 api/core/v1alpha1/nattable_types.go create mode 100644 api/core/v1alpha1/network_types.go create mode 100644 api/core/v1alpha1/networkid_types.go create mode 100644 api/core/v1alpha1/networkinterface_types.go create mode 100644 api/core/v1alpha1/node_types.go create mode 100644 api/core/v1alpha1/register.go create mode 100644 api/core/v1alpha1/well_known_annotations.go create mode 100644 api/core/v1alpha1/well_known_labels.go create mode 100644 api/core/v1alpha1/zz_generated.deepcopy.go delete mode 100644 api/v1alpha1/network_types.go delete mode 100644 api/v1alpha1/publicip_types.go delete mode 100644 api/v1alpha1/zz_generated.deepcopy.go rename api/v1alpha1/common_types.go => apimachinery/api/net/net.go (50%) create mode 100644 apimachinery/equality/semantic.go rename onmetal-api-net/controllers/events.go => apinetlet/client/client.go (79%) create mode 100644 apinetlet/client/sourceaware.go create mode 100644 apinetlet/controllers/conversion.go create mode 100644 apinetlet/controllers/helper_test.go create mode 100644 apinetlet/controllers/networkinterface_controller.go create mode 100644 apinetlet/controllers/networkinterface_controller_test.go create mode 100644 apinetlet/handler/sourceaware.go create mode 100644 apinetlet/provider/provider.go create mode 100644 apinetlet/provider/provider_suite_test.go create mode 100644 apinetlet/provider/provider_test.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/affinity.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/daemonset.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/daemonsetspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/daemonsetstatus.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instance.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instanceaffinityterm.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instanceantiaffinity.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instancespec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instancestatus.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/instancetemplate.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ip.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ipaddress.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ipaddressclaimref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ipaddressspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ipclaimref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/ipspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancer.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerdestination.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerip.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerport.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerrouting.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancerstatus.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/loadbalancertargetref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgateway.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgatewayautoscaler.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgatewayautoscalerspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgatewayip.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgatewayspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natgatewaystatus.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natip.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/natipsection.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nattable.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nattableiptargetref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/network.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkid.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkidclaimref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkidspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterface.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterfacenat.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterfacenatclaimref.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterfacepublicip.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterfacespec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkinterfacestatus.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/networkspec.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/node.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nodeaffinity.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nodeselector.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nodeselectorrequirement.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/nodeselectorterm.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/pciaddress.go create mode 100644 client-go/applyconfigurations/core/v1alpha1/topologyspreadconstraint.go create mode 100644 client-go/applyconfigurations/internal/internal.go create mode 100644 client-go/applyconfigurations/meta/v1/labelselector.go create mode 100644 client-go/applyconfigurations/meta/v1/labelselectorrequirement.go create mode 100644 client-go/applyconfigurations/meta/v1/managedfieldsentry.go create mode 100644 client-go/applyconfigurations/meta/v1/objectmeta.go create mode 100644 client-go/applyconfigurations/meta/v1/ownerreference.go create mode 100644 client-go/applyconfigurations/meta/v1/typemeta.go create mode 100644 client-go/applyconfigurations/utils.go create mode 100644 client-go/informers/core/interface.go create mode 100644 client-go/informers/core/v1alpha1/daemonset.go create mode 100644 client-go/informers/core/v1alpha1/instance.go create mode 100644 client-go/informers/core/v1alpha1/interface.go create mode 100644 client-go/informers/core/v1alpha1/ip.go create mode 100644 client-go/informers/core/v1alpha1/ipaddress.go create mode 100644 client-go/informers/core/v1alpha1/loadbalancer.go create mode 100644 client-go/informers/core/v1alpha1/loadbalancerrouting.go create mode 100644 client-go/informers/core/v1alpha1/natgateway.go create mode 100644 client-go/informers/core/v1alpha1/natgatewayautoscaler.go create mode 100644 client-go/informers/core/v1alpha1/nattable.go create mode 100644 client-go/informers/core/v1alpha1/network.go create mode 100644 client-go/informers/core/v1alpha1/networkid.go create mode 100644 client-go/informers/core/v1alpha1/networkinterface.go create mode 100644 client-go/informers/core/v1alpha1/node.go create mode 100644 client-go/informers/factory.go create mode 100644 client-go/informers/generic.go create mode 100644 client-go/informers/internalinterfaces/factory_interfaces.go create mode 100644 client-go/listers/core/v1alpha1/daemonset.go create mode 100644 client-go/listers/core/v1alpha1/expansion_generated.go create mode 100644 client-go/listers/core/v1alpha1/instance.go create mode 100644 client-go/listers/core/v1alpha1/ip.go create mode 100644 client-go/listers/core/v1alpha1/ipaddress.go create mode 100644 client-go/listers/core/v1alpha1/loadbalancer.go create mode 100644 client-go/listers/core/v1alpha1/loadbalancerrouting.go create mode 100644 client-go/listers/core/v1alpha1/natgateway.go create mode 100644 client-go/listers/core/v1alpha1/natgatewayautoscaler.go create mode 100644 client-go/listers/core/v1alpha1/nattable.go create mode 100644 client-go/listers/core/v1alpha1/network.go create mode 100644 client-go/listers/core/v1alpha1/networkid.go create mode 100644 client-go/listers/core/v1alpha1/networkinterface.go create mode 100644 client-go/listers/core/v1alpha1/node.go create mode 100644 client-go/onmetalapinet/clientset.go create mode 100644 client-go/onmetalapinet/fake/clientset_generated.go create mode 100644 client-go/onmetalapinet/fake/doc.go create mode 100644 client-go/onmetalapinet/fake/register.go create mode 100644 client-go/onmetalapinet/scheme/doc.go create mode 100644 client-go/onmetalapinet/scheme/register.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/core_client.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/daemonset.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/doc.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/doc.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_core_client.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_daemonset.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_instance.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ip.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ipaddress.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancer.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancerrouting.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgateway.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgatewayautoscaler.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_nattable.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_network.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkid.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkinterface.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_node.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/generated_expansion.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/instance.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/ip.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/ipaddress.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/loadbalancer.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/loadbalancerrouting.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/natgateway.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/natgatewayautoscaler.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/nattable.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/network.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/networkid.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/networkinterface.go create mode 100644 client-go/onmetalapinet/typed/core/v1alpha1/node.go create mode 100644 client-go/openapi/api_violations.report create mode 100644 client-go/openapi/zz_generated.openapi.go rename {apinetlet => cmd/apinetlet}/main.go (87%) create mode 100644 cmd/apiserver/main.go rename {onmetal-api-net => cmd/controller-manager}/main.go (62%) rename {metalnetlet => cmd/metalnetlet}/main.go (75%) create mode 100644 config/apiserver/apiservice/bases/kustomization.yaml create mode 100644 config/apiserver/apiservice/bases/v1alpha1.core.apinet.api.onmetal.de.yaml create mode 100644 config/apiserver/apiservice/kustomization.yaml create mode 100644 config/apiserver/apiservice/kustomizeconfig.yaml create mode 100644 config/apiserver/apiservice/patch-apiservice.yaml create mode 100644 config/apiserver/apiservice/service.yaml create mode 100644 config/apiserver/certmanager/certificate.yaml create mode 100644 config/apiserver/certmanager/kustomization.yaml create mode 100644 config/apiserver/certmanager/kustomizeconfig.yaml create mode 100644 config/apiserver/default/apiserver_certificate_patch.yaml create mode 100644 config/apiserver/default/apiservicecainjection_patch.yaml create mode 100644 config/apiserver/default/kustomization.yaml create mode 100644 config/apiserver/etcd/etcd.yaml create mode 100644 config/apiserver/etcd/kustomization.yaml create mode 100644 config/apiserver/etcd/service.yaml create mode 100644 config/apiserver/etcdless/apiserver_certificate_patch.yaml create mode 100644 config/apiserver/etcdless/apiservicecainjection_patch.yaml create mode 100644 config/apiserver/etcdless/kustomization.yaml create mode 100644 config/apiserver/kind/kustomization.yaml create mode 100644 config/apiserver/kind/patch-apiserver.yaml create mode 100644 config/apiserver/rbac/apiserver_role.yaml create mode 100644 config/apiserver/rbac/apiserver_role_binding.yaml create mode 100644 config/apiserver/rbac/apiserver_service_account.yaml create mode 100644 config/apiserver/rbac/bucketpool_bootstrapper_role.yaml create mode 100644 config/apiserver/rbac/bucketpool_bootstrapper_rolebinding.yaml rename config/{onmetal-api-net/rbac/role.yaml => apiserver/rbac/bucketpool_role.yaml} (59%) create mode 100644 config/apiserver/rbac/bucketpool_rolebinding.yaml create mode 100644 config/apiserver/rbac/kustomization.yaml create mode 100644 config/apiserver/rbac/machinepool_bootstrapper_role.yaml create mode 100644 config/apiserver/rbac/machinepool_bootstrapper_rolebinding.yaml create mode 100644 config/apiserver/rbac/machinepool_role.yaml create mode 100644 config/apiserver/rbac/machinepool_rolebinding.yaml create mode 100644 config/apiserver/rbac/networkplugin_bootstrapper_role.yaml create mode 100644 config/apiserver/rbac/networkplugin_bootstrapper_rolebinding.yaml create mode 100644 config/apiserver/rbac/networkplugin_role.yaml create mode 100644 config/apiserver/rbac/networkplugin_rolebinding.yaml create mode 100644 config/apiserver/rbac/volumepool_bootstrapper_role.yaml create mode 100644 config/apiserver/rbac/volumepool_bootstrapper_rolebinding.yaml create mode 100644 config/apiserver/rbac/volumepool_role.yaml create mode 100644 config/apiserver/rbac/volumepool_rolebinding.yaml create mode 100644 config/apiserver/server/kustomization.yaml create mode 100644 config/apiserver/server/server.yaml rename config/{onmetal-api-net => controller}/default/kustomization.yaml (99%) rename config/{onmetal-api-net => controller}/default/manager_auth_proxy_patch.yaml (100%) rename config/{onmetal-api-net => controller}/default/manager_config_patch.yaml (100%) rename config/{onmetal-api-net => controller}/kind/add-manager-args.yaml (100%) rename config/{onmetal-api-net => controller}/kind/kustomization.yaml (100%) rename config/{onmetal-api-net => controller}/kind/patch-controller.yaml (100%) rename config/{onmetal-api-net => controller}/manager/controller_manager_config.yaml (100%) rename config/{onmetal-api-net => controller}/manager/kustomization.yaml (100%) rename config/{onmetal-api-net => controller}/manager/manager.yaml (100%) rename config/{onmetal-api-net => controller}/prometheus/kustomization.yaml (100%) rename config/{onmetal-api-net => controller}/prometheus/monitor.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/apinetlet_bootstrapper_role.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/apinetlet_bootstrapper_rolebinding.yaml (100%) create mode 100644 config/controller/rbac/apinetlet_role.yaml rename config/{onmetal-api-net => controller}/rbac/apinetlet_rolebinding.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/auth_proxy_client_clusterrole.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/auth_proxy_role.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/auth_proxy_role_binding.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/auth_proxy_service.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/kustomization.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/leader_election_role.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/leader_election_role_binding.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/metalnetlet_bootstrapper_role.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/metalnetlet_bootstrapper_rolebinding.yaml (100%) create mode 100644 config/controller/rbac/metalnetlet_role.yaml rename config/{onmetal-api-net => controller}/rbac/metalnetlet_rolebinding.yaml (100%) create mode 100644 config/controller/rbac/role.yaml rename config/{onmetal-api-net => controller}/rbac/role_binding.yaml (100%) rename config/{onmetal-api-net => controller}/rbac/service_account.yaml (100%) create mode 100644 config/default/apiserver/kustomization.yaml create mode 100644 config/default/apiserver/remove-namespace.yaml create mode 100644 config/default/controller/kustomization.yaml create mode 100644 config/default/controller/remove-namespace.yaml create mode 100644 config/default/kustomization.yaml create mode 100644 config/default/namespace.yaml create mode 100644 config/etcdless/apiserver/kustomization.yaml create mode 100644 config/etcdless/apiserver/remove-namespace.yaml create mode 100644 config/etcdless/controller/kustomization.yaml create mode 100644 config/etcdless/controller/remove-namespace.yaml create mode 100644 config/etcdless/kustomization.yaml create mode 100644 config/etcdless/namespace.yaml delete mode 100644 config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_networks.yaml delete mode 100644 config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_publicips.yaml delete mode 100644 config/onmetal-api-net/crd/kustomization.yaml delete mode 100644 config/onmetal-api-net/crd/kustomizeconfig.yaml delete mode 100644 config/onmetal-api-net/rbac/apinetlet_role.yaml delete mode 100644 config/onmetal-api-net/rbac/metalnetlet_role.yaml delete mode 100644 config/onmetal-api-net/samples/apinet_v1alpha1_network.yaml delete mode 100644 config/onmetal-api-net/samples/apinet_v1alpha1_publicip.yaml create mode 100755 hack/cluster-controller-gen.sh create mode 100755 hack/promote-let-role.sh create mode 100755 hack/types-to-internal-types.sh create mode 100755 hack/update-codegen.sh create mode 100644 internal/apis/core/common_types.go create mode 100644 internal/apis/core/daemonset_types.go create mode 100644 internal/apis/core/doc.go create mode 100644 internal/apis/core/install/install.go create mode 100644 internal/apis/core/instance_types.go create mode 100644 internal/apis/core/ip_types.go create mode 100644 internal/apis/core/ipaddress_types.go create mode 100644 internal/apis/core/loadbalancer_types.go create mode 100644 internal/apis/core/loadbalancerrouting_types.go create mode 100644 internal/apis/core/natgateway_types.go create mode 100644 internal/apis/core/natgatewayautoscaler_types.go create mode 100644 internal/apis/core/nattable_types.go create mode 100644 internal/apis/core/network_types.go create mode 100644 internal/apis/core/networkid_types.go create mode 100644 internal/apis/core/networkinterface_types.go create mode 100644 internal/apis/core/node_types.go create mode 100644 internal/apis/core/register.go create mode 100644 internal/apis/core/v1alpha1/conversions.go create mode 100644 internal/apis/core/v1alpha1/defaults.go create mode 100644 internal/apis/core/v1alpha1/doc.go rename api/v1alpha1/groupversion_info.go => internal/apis/core/v1alpha1/register.go (58%) create mode 100644 internal/apis/core/v1alpha1/zz_generated.conversion.go create mode 100644 internal/apis/core/v1alpha1/zz_generated.defaults.go create mode 100644 internal/apis/core/validation/daemonset.go create mode 100644 internal/apis/core/validation/instance.go create mode 100644 internal/apis/core/validation/ip.go create mode 100644 internal/apis/core/validation/ipaddress.go create mode 100644 internal/apis/core/validation/loadbalancer.go create mode 100644 internal/apis/core/validation/loadbalancerrouting.go create mode 100644 internal/apis/core/validation/natgateway.go create mode 100644 internal/apis/core/validation/natgatewayautoscaler.go create mode 100644 internal/apis/core/validation/nattable.go create mode 100644 internal/apis/core/validation/network.go create mode 100644 internal/apis/core/validation/networkid.go create mode 100644 internal/apis/core/validation/networkinterface.go create mode 100644 internal/apis/core/validation/node.go create mode 100644 internal/apis/core/well_known_annotations.go create mode 100644 internal/apis/core/well_known_labels.go create mode 100644 internal/apis/core/zz_generated.deepcopy.go create mode 100644 internal/apiserver/apiserver.go create mode 100644 internal/app/apiserver/apiserver.go create mode 100644 internal/app/app_suite_test.go create mode 100644 internal/app/core_test.go create mode 100644 internal/client/client.go rename {onmetal-api-net => internal}/controllers/certificate/generic/certificate.go (100%) rename {onmetal-api-net => internal}/controllers/certificate/onmetal-api-net/apinetlet.go (94%) rename {onmetal-api-net => internal}/controllers/certificate/onmetal-api-net/metalnetlet.go (94%) rename {onmetal-api-net => internal}/controllers/certificate/onmetal-api-net/onmetalapinet.go (88%) rename {onmetal-api-net => internal}/controllers/certificateapproval_controller.go (98%) rename {onmetal-api-net => internal}/controllers/certificateapproval_test.go (96%) create mode 100644 internal/controllers/common_test.go create mode 100644 internal/controllers/controllers_suite_test.go create mode 100644 internal/controllers/daemonset_controller.go create mode 100644 internal/controllers/daemonset_controller_test.go create mode 100644 internal/controllers/helper.go create mode 100644 internal/controllers/ipaddressgc_controller.go create mode 100644 internal/controllers/ipaddressgc_controller_test.go create mode 100644 internal/controllers/loadbalancer_controller.go create mode 100644 internal/controllers/loadbalancer_controller_test.go create mode 100644 internal/controllers/natgateway_controller.go create mode 100644 internal/controllers/natgateway_controller_test.go create mode 100644 internal/controllers/natgatewayautoscaler_controller.go create mode 100644 internal/controllers/natgatewayautoscaler_controller_test.go create mode 100644 internal/controllers/networkidgc_controller.go create mode 100644 internal/controllers/scheduler/cache.go create mode 100644 internal/controllers/scheduler_controller.go create mode 100644 internal/controllers/scheduler_controller_test.go create mode 100644 internal/controllers/util.go create mode 100644 internal/natgateway/allocation.go create mode 100644 internal/natgateway/autoscaler.go create mode 100644 internal/nodeaffinity/nodeaffinity.go create mode 100644 internal/registry/daemonset/storage.go create mode 100644 internal/registry/daemonset/strategy.go create mode 100644 internal/registry/daemonset/tableconvertor.go create mode 100644 internal/registry/instance/storage.go create mode 100644 internal/registry/instance/strategy.go create mode 100644 internal/registry/instance/tableconvertor.go create mode 100644 internal/registry/ip/ipaddressallocator/ipaddressallocator.go create mode 100644 internal/registry/ip/storage.go create mode 100644 internal/registry/ip/strategy.go create mode 100644 internal/registry/ip/tableconvertor.go create mode 100644 internal/registry/ipaddress/storage.go create mode 100644 internal/registry/ipaddress/strategy.go create mode 100644 internal/registry/ipaddress/tableconvertor.go create mode 100644 internal/registry/ipallocator/allocators.go create mode 100644 internal/registry/ipallocator/ipallocator.go create mode 100644 internal/registry/loadbalancer/storage.go create mode 100644 internal/registry/loadbalancer/strategy.go create mode 100644 internal/registry/loadbalancer/tableconvertor.go create mode 100644 internal/registry/loadbalancerrouting/storage.go create mode 100644 internal/registry/loadbalancerrouting/strategy.go create mode 100644 internal/registry/loadbalancerrouting/tableconvertor.go create mode 100644 internal/registry/natgateway/storage.go create mode 100644 internal/registry/natgateway/strategy.go create mode 100644 internal/registry/natgateway/tableconvertor.go create mode 100644 internal/registry/natgatewayautoscaler/storage.go create mode 100644 internal/registry/natgatewayautoscaler/strategy.go create mode 100644 internal/registry/natgatewayautoscaler/tableconvertor.go create mode 100644 internal/registry/nattable/storage.go create mode 100644 internal/registry/nattable/strategy.go create mode 100644 internal/registry/nattable/tableconvertor.go create mode 100644 internal/registry/network/networkidallocator/networkidallocator.go create mode 100644 internal/registry/network/storage.go create mode 100644 internal/registry/network/strategy.go create mode 100644 internal/registry/network/tableconvertor.go create mode 100644 internal/registry/networkid/storage.go create mode 100644 internal/registry/networkid/strategy.go create mode 100644 internal/registry/networkid/tableconvertor.go create mode 100644 internal/registry/networkinterface/storage.go create mode 100644 internal/registry/networkinterface/strategy.go create mode 100644 internal/registry/networkinterface/tableconvertor.go create mode 100644 internal/registry/node/storage.go create mode 100644 internal/registry/node/strategy.go create mode 100644 internal/registry/node/tableconvertor.go create mode 100644 metalnetlet/client/client.go create mode 100644 metalnetlet/client/sourceaware.go create mode 100644 metalnetlet/controllers/common.go create mode 100644 metalnetlet/controllers/conversion.go create mode 100644 metalnetlet/controllers/instance_controller.go create mode 100644 metalnetlet/controllers/instance_controller_test.go create mode 100644 metalnetlet/controllers/metalnetnode_controller.go create mode 100644 metalnetlet/controllers/metalnetnode_controller_test.go create mode 100644 metalnetlet/controllers/networkinterface_controller.go create mode 100644 metalnetlet/controllers/networkinterface_controller_test.go delete mode 100644 metalnetlet/controllers/testdata/metalnet-crds/network.yaml create mode 100644 metalnetlet/handler/sourceaware.go create mode 100644 models-schema/main.go create mode 100644 models-schema/main.go.tmpl create mode 100644 networkid/networkid.go delete mode 100644 onmetal-api-net/controllers/controllers_suite_test.go delete mode 100644 onmetal-api-net/controllers/network_controller.go delete mode 100644 onmetal-api-net/controllers/network_controller_test.go delete mode 100644 onmetal-api-net/controllers/publicip_controller.go delete mode 100644 onmetal-api-net/controllers/publicip_controller_test.go delete mode 100644 onmetal-api-net/controllers/util.go create mode 100644 utils/api/sourceaware.go create mode 100644 utils/cache/util.go create mode 100644 utils/client/sourceaware.go create mode 100644 utils/container/bimap.go create mode 100644 utils/container/rmap.go create mode 100644 utils/container/slots.go create mode 100644 utils/controller/refmanager.go rename apiutils/apiutils.go => utils/core/core.go (68%) create mode 100644 utils/expectations/expectations.go create mode 100644 utils/generic/generic.go create mode 100644 utils/handler/expectations.go create mode 100644 utils/handler/sourceaware.go create mode 100644 utils/hash/hash.go create mode 100644 utils/iterator/iterator.go create mode 100644 utils/netip/netip.go create mode 100644 utils/slots/slots.go create mode 100644 utils/testing/testing.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ffbf17e7..28da55a4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,4 +21,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.51.1 + version: v1.54.2 diff --git a/.golangci.yaml b/.golangci.yaml index 9f4ebf1f..f0f79b28 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -13,9 +13,14 @@ severity: default-severity: error linters-settings: + misspell: + ignore-words: + - strat revive: severity: error rules: - - name: exported - - name: if-return - disabled: true + - name: exported + arguments: + - disableStutteringCheck + - name: if-return + disabled: true diff --git a/Makefile b/Makefile index a83cf173..a3e4d00b 100644 --- a/Makefile +++ b/Makefile @@ -46,22 +46,35 @@ help: ## Display this help. ##@ Development .PHONY: manifests -manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role crd paths="./api/...;./onmetal-api-net/..." output:crd:artifacts:config=config/onmetal-api-net/crd/bases output:rbac:artifacts:config=config/onmetal-api-net/rbac +manifests: controller-gen ## Generate rbac objects. + # onmetal-api-net + $(CONTROLLER_GEN) rbac:roleName=manager-role paths="./internal/controllers/..." output:rbac:artifacts:config=config/onmetal-api-net/rbac # apinetlet - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./apinetlet/..." output:rbac:artifacts:config=config/apinetlet/rbac - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./metalnetlet/..." output:rbac:artifacts:config=config/metalnetlet/rbac + $(CONTROLLER_GEN) rbac:roleName=manager-role paths="./apinetlet/controllers/..." output:rbac:artifacts:config=config/apinetlet/rbac + CONTROLLER_GEN=$(CONTROLLER_GEN) ./hack/cluster-controller-gen.sh cluster=apinet rbac:roleName=apinet-role paths="./apinetlet/controllers/..." output:rbac:artifacts:config=config/apinetlet/apinet-rbac - # poollet system roles - cp config/apinetlet/apinet-rbac/role.yaml config/onmetal-api-net/rbac/apinetlet_role.yaml - ./hack/replace.sh config/onmetal-api-net/rbac/apinetlet_role.yaml 's/apinet-role/apinet.api.onmetal.de:system:apinetlets/g' - ./hack/replace.sh config/onmetal-api-net/rbac/apinetlet_role.yaml 's/Role/ClusterRole/g' - ./hack/replace.sh config/onmetal-api-net/rbac/apinetlet_role.yaml '/namespace: system/d' + # metalnetlet + $(CONTROLLER_GEN) rbac:roleName=manager-role paths="./metalnetlet/controllers/..." output:rbac:artifacts:config=config/metalnetlet/rbac + CONTROLLER_GEN=$(CONTROLLER_GEN) ./hack/cluster-controller-gen.sh cluster=metalnet rbac:roleName=metalnet-role paths="./metalnetlet/controllers/..." output:rbac:artifacts:config=config/metalnetlet/metalnet-rbac + + # Promote *let roles. + ./hack/promote-let-role.sh config/apinetlet/apinet-rbac/role.yaml config/onmetal-api-net/rbac/apinetlet_role.yaml apinet.api.onmetal.de:system:apinetlets + ./hack/promote-let-role.sh config/metalnetlet/metalnet-rbac/role.yaml config/onmetal-api-net/rbac/metalnetlet_role.yaml apinet.api.onmetal.de:system:metalnetlet .PHONY: generate -generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." +generate: vgopath models-schema deepcopy-gen client-gen lister-gen informer-gen defaulter-gen conversion-gen openapi-gen applyconfiguration-gen + VGOPATH=$(VGOPATH) \ + MODELS_SCHEMA=$(MODELS_SCHEMA) \ + DEEPCOPY_GEN=$(DEEPCOPY_GEN) \ + CLIENT_GEN=$(CLIENT_GEN) \ + LISTER_GEN=$(LISTER_GEN) \ + INFORMER_GEN=$(INFORMER_GEN) \ + DEFAULTER_GEN=$(DEFAULTER_GEN) \ + CONVERSION_GEN=$(CONVERSION_GEN) \ + OPENAPI_GEN=$(OPENAPI_GEN) \ + APPLYCONFIGURATION_GEN=$(APPLYCONFIGURATION_GEN) \ + ./hack/update-codegen.sh .PHONY: add-license add-license: addlicense ## Add license headers to all go files. @@ -79,8 +92,16 @@ check-license: addlicense ## Check that every file has a license header present. lint: ## Run golangci-lint against code. golangci-lint run ./... +.PHONY: clean +clean: ## Clean any artifacts that can be regenerated. + rm -rf client-go/applyconfigurations + rm -rf client-go/informers + rm -rf client-go/listers + rm -rf client-go/onmetalapi + rm -rf client-go/openapi + .PHONY: check -check: manifests generate add-license fmt lint test ## Lint and run tests. +check: generate manifests add-license fmt lint test ## Lint and run tests. ENVTEST_ASSETS_DIR=$(shell pwd)/testbin .PHONY: test @@ -299,12 +320,28 @@ $(LOCALBIN): KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest +OPENAPI_EXTRACTOR ?= $(LOCALBIN)/openapi-extractor +DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen +CLIENT_GEN ?= $(LOCALBIN)/client-gen +LISTER_GEN ?= $(LOCALBIN)/lister-gen +INFORMER_GEN ?= $(LOCALBIN)/informer-gen +DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen +CONVERSION_GEN ?= $(LOCALBIN)/conversion-gen +OPENAPI_GEN ?= $(LOCALBIN)/openapi-gen +APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen +VGOPATH ?= $(LOCALBIN)/vgopath +GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs ADDLICENSE ?= $(LOCALBIN)/addlicense +MODELS_SCHEMA ?= $(LOCALBIN)/models-schema GOIMPORTS ?= $(LOCALBIN)/goimports ## Tool Versions KUSTOMIZE_VERSION ?= v5.0.0 -CONTROLLER_TOOLS_VERSION ?= v0.12.0 +CODE_GENERATOR_VERSION ?= v0.27.2 +VGOPATH_VERSION ?= v0.1.1 +CONTROLLER_TOOLS_VERSION ?= v0.11.3 +VGOPATH_VERSION ?= v0.0.2 +GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0 ADDLICENSE_VERSION ?= v1.1.0 GOIMPORTS_VERSION ?= v0.5.0 @@ -318,20 +355,86 @@ $(KUSTOMIZE): $(LOCALBIN) fi test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); } -.PHONY: addlicense -addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary. -$(ADDLICENSE): $(LOCALBIN) - test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION) - .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. $(CONTROLLER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) +.PHONY: deepcopy-gen +deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary. +$(DEEPCOPY_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: client-gen +client-gen: $(CLIENT_GEN) ## Download client-gen locally if necessary. +$(CLIENT_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: lister-gen +lister-gen: $(LISTER_GEN) ## Download lister-gen locally if necessary. +$(LISTER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: informer-gen +informer-gen: $(INFORMER_GEN) ## Download informer-gen locally if necessary. +$(INFORMER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: defaulter-gen +defaulter-gen: $(DEFAULTER_GEN) ## Download defaulter-gen locally if necessary. +$(DEFAULTER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/defaulter-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/defaulter-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: conversion-gen +conversion-gen: $(CONVERSION_GEN) ## Download conversion-gen locally if necessary. +$(CONVERSION_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/conversion-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/conversion-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: openapi-gen +openapi-gen: $(OPENAPI_GEN) ## Download openapi-gen locally if necessary. +$(OPENAPI_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/openapi-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/openapi-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: applyconfiguration-gen +applyconfiguration-gen: $(APPLYCONFIGURATION_GEN) ## Download applyconfiguration-gen locally if necessary. +$(APPLYCONFIGURATION_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODE_GENERATOR_VERSION) + +.PHONY: vgopath +vgopath: $(VGOPATH) ## Download vgopath locally if necessary. +.PHONY: $(VGOPATH) +$(VGOPATH): $(LOCALBIN) + @if test -x $(LOCALBIN)/vgopath && ! $(LOCALBIN)/vgopath version | grep -q $(VGOPATH_VERSION); then \ + echo "$(LOCALBIN)/vgopath version is not expected $(VGOPATH_VERSION). Removing it before installing."; \ + rm -rf $(LOCALBIN)/vgopath; \ + fi + test -s $(LOCALBIN)/vgopath || GOBIN=$(LOCALBIN) go install github.com/onmetal/vgopath@$(VGOPATH_VERSION) + .PHONY: envtest envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) - GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + +.PHONY: openapi-extractor +openapi-extractor: $(OPENAPI_EXTRACTOR) ## Download openapi-extractor locally if necessary. +$(OPENAPI_EXTRACTOR): $(LOCALBIN) + test -s $(LOCALBIN)/openapi-extractor || GOBIN=$(LOCALBIN) go install github.com/onmetal/openapi-extractor/cmd/openapi-extractor@latest + +.PHONY: gen-crd-api-reference-docs +gen-crd-api-reference-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Download gen-crd-api-reference-docs locally if necessary. +$(GEN_CRD_API_REFERENCE_DOCS): $(LOCALBIN) + test -s $(LOCALBIN)/gen-crd-api-reference-docs || GOBIN=$(LOCALBIN) go install github.com/ahmetb/gen-crd-api-reference-docs@$(GEN_CRD_API_REFERENCE_DOCS_VERSION) + +.PHONY: addlicense +addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary. +$(ADDLICENSE): $(LOCALBIN) + test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION) + +.PHONY: models-schema +models-schema: $(MODELS_SCHEMA) ## Install models-schema locally if necessary. +$(MODELS_SCHEMA): $(LOCALBIN) + test -s $(LOCALBIN)/models-schema || GOBIN=$(LOCALBIN) go install github.com/onmetal/onmetal-api-net/models-schema .PHONY: goimports goimports: $(GOIMPORTS) ## Download goimports locally if necessary. diff --git a/api/core/v1alpha1/common_types.go b/api/core/v1alpha1/common_types.go new file mode 100644 index 00000000..c5310646 --- /dev/null +++ b/api/core/v1alpha1/common_types.go @@ -0,0 +1,41 @@ +// Copyright 2022 OnMetal 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 + +const ( + ReconcileRequestAnnotation = "reconcile.apinet.api.onmetal.de/requestedAt" + + // APINetletsGroup is the system rbac group all apinetlets are in. + APINetletsGroup = "apinet.api.onmetal.de:system:apinetlets" + + // APINetletUserNamePrefix is the prefix all apinetlet users should have. + APINetletUserNamePrefix = "apinet.api.onmetal.de:system:apinetlet:" + + // MetalnetletsGroup is the system rbac group all metalnetlets are in. + MetalnetletsGroup = "apinet.api.onmetal.de:system:metalnetlets" + + // MetalnetletUserNamePrefix is the prefix all metalnetlet users should have. + MetalnetletUserNamePrefix = "apinet.api.onmetal.de:system:metalnetlet:" +) + +// APINetletCommonName constructs the common name for a certificate of an apinetlet user. +func APINetletCommonName(name string) string { + return APINetletUserNamePrefix + name +} + +// MetalnetletCommonName constructs the common name for a certificate of a metalnetlet user. +func MetalnetletCommonName(name string) string { + return MetalnetletUserNamePrefix + name +} diff --git a/api/core/v1alpha1/daemonset_types.go b/api/core/v1alpha1/daemonset_types.go new file mode 100644 index 00000000..1201e51d --- /dev/null +++ b/api/core/v1alpha1/daemonset_types.go @@ -0,0 +1,52 @@ +// Copyright 2023 OnMetal 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" +) + +type DaemonSetSpec struct { + // Selector selects all Instance that are managed by this daemon set. + Selector *metav1.LabelSelector `json:"nodeSelector,omitempty"` + + // Template is the instance template. + Template InstanceTemplate `json:"template"` +} + +type DaemonSetStatus struct { + CollisionCount *int32 `json:"collisionCount,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// DaemonSet is the schema for the daemonsets API. +type DaemonSet struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec DaemonSetSpec `json:"spec,omitempty"` + Status DaemonSetStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DaemonSetList contains a list of DaemonSet. +type DaemonSetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DaemonSet `json:"items"` +} diff --git a/api/core/v1alpha1/doc.go b/api/core/v1alpha1/doc.go new file mode 100644 index 00000000..ae0eccaa --- /dev/null +++ b/api/core/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 by the OnMetal 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. + */ + +// +k8s:deepcopy-gen=package +// +k8s:openapi-gen=true +// +k8s:defaulter-gen=TypeMeta +// +k8s:protobuf-gen=package +// +groupName=core.apinet.api.onmetal.de + +// Package v1alpha1 is the v1alpha1 version of the API. +package v1alpha1 // import "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" diff --git a/api/core/v1alpha1/instance_types.go b/api/core/v1alpha1/instance_types.go new file mode 100644 index 00000000..df3dc946 --- /dev/null +++ b/api/core/v1alpha1/instance_types.go @@ -0,0 +1,196 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type InstanceType string + +const ( + InstanceTypeLoadBalancer InstanceType = "LoadBalancer" +) + +type InstanceSpec struct { + // Type specifies the InstanceType to deploy. + Type InstanceType `json:"type"` + + // LoadBalancerType is the load balancer type this instance is for. + LoadBalancerType LoadBalancerType `json:"loadBalancerType"` + + // NetworkRef references the network the instance is on. + NetworkRef corev1.LocalObjectReference `json:"networkRef"` + + // IPs are the IPs of the instance. + IPs []net.IP `json:"ips,omitempty"` + + // LoadBalancerPorts are the load balancer ports of this instance. + LoadBalancerPorts []LoadBalancerPort `json:"loadBalancerPorts,omitempty"` + + // Affinity are affinity constraints. + Affinity *Affinity `json:"affinity,omitempty"` + + // TopologySpreadConstraints describes how a group of instances ought to spread across topology + // domains. Scheduler will schedule instances in a way which abides by the constraints. + // All topologySpreadConstraints are ANDed. + TopologySpreadConstraints []TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` + + // NodeRef references the node hosting the load balancer instance. + // Will be set by the scheduler if empty. + NodeRef *corev1.LocalObjectReference `json:"nodeRef,omitempty"` +} + +type Affinity struct { + NodeAffinity *NodeAffinity `json:"nodeAffinity,omitempty"` + InstanceAntiAffinity *InstanceAntiAffinity `json:"instanceAntiAffinity,omitempty"` +} + +type InstanceAntiAffinity struct { + // RequiredDuringSchedulingIgnoredDuringExecution specifies anti-affinity requirements at + // scheduling time, that, if not met, will cause the instance not be scheduled onto the node. + // When there are multiple elements, the lists of nodes corresponding to each + // instanceAffinityTerm are intersected, i.e. all terms must be satisfied. + RequiredDuringSchedulingIgnoredDuringExecution []InstanceAffinityTerm `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"` +} + +// InstanceAffinityTerm defines a set of instances (namely those matching the labelSelector that this instance should be +// co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose +// value of the label with key matches that of any node on which a instance of the set of instances is running. +type InstanceAffinityTerm struct { + // LabelSelector over a set of resources, in this case instances. + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` + // TopologyKey indicates that this instance should be co-located (affinity) or not co-located (anti-affinity) + // with the instances matching the labelSelector, where co-located is defined as running on a + // node whose value of the label with key topologyKey matches that of any node on which any of the + // selected instances is running. + // Empty topologyKey is not allowed. + TopologyKey string `json:"topologyKey"` +} + +type NodeAffinity struct { + RequiredDuringSchedulingIgnoredDuringExecution *NodeSelector `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"` +} + +// NodeSelector represents the union of the results of one or more queries +// over a set of nodes; that is, it represents the OR of the selectors represented +// by the node selector terms. +type NodeSelector struct { + // Required. A list of node selector terms. The terms are ORed. + NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms"` +} + +// NodeSelectorTerm matches no objects if it's empty. The requirements of the selector are ANDed. +type NodeSelectorTerm struct { + // MatchExpressions matches nodes by the label selector requirements. + MatchExpressions []NodeSelectorRequirement `json:"matchExpressions,omitempty"` + // MatchFields matches the nodes by their fields. + MatchFields []NodeSelectorRequirement `json:"matchFields,omitempty"` +} + +// NodeSelectorRequirement is a requirement for a selector. It's a combination of the key to match, the operator +// to match with, and zero to n values, depending on the operator. +type NodeSelectorRequirement struct { + // Key is the key the selector applies to. + Key string `json:"key"` + // Operator represents the key's relationship to the values. + // Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + Operator NodeSelectorOperator `json:"operator"` + // Values are the values to relate the key to via the operator. + Values []string `json:"values,omitempty"` +} + +// NodeSelectorOperator is the set of operators that can be used in +// a node selector requirement. +type NodeSelectorOperator string + +const ( + NodeSelectorOpIn NodeSelectorOperator = "In" + NodeSelectorOpNotIn NodeSelectorOperator = "NotIn" + NodeSelectorOpExists NodeSelectorOperator = "Exists" + NodeSelectorOpDoesNotExist NodeSelectorOperator = "DoesNotExist" + NodeSelectorOpGt NodeSelectorOperator = "Gt" + NodeSelectorOpLt NodeSelectorOperator = "Lt" +) + +type UnsatisfiableConstraintAction string + +const ( + // DoNotSchedule instructs the scheduler not to schedule the instance + // when constraints are not satisfied. + DoNotSchedule UnsatisfiableConstraintAction = "DoNotSchedule" +) + +// TopologySpreadConstraint specifies how to spread matching instances among the given topology. +type TopologySpreadConstraint struct { + // MaxSkew describes the degree to which instances may be unevenly distributed. + // When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference + // between the number of matching instances in the target topology and the global minimum. + // The global minimum is the minimum number of matching instances in an eligible domain + // or zero if the number of eligible domains is less than MinDomains. + MaxSkew int32 `json:"maxSkew"` + // TopologyKey is the key of node labels. Nodes that have a label with this key + // and identical values are considered to be in the same topology. + // We consider each as a "bucket", and try to put balanced number + // of instances into each bucket. + // We define a domain as a particular instance of a topology. + // Also, we define an eligible domain as a domain whose nodes meet the requirements of + // nodeAffinityPolicy and nodeTaintsPolicy. + TopologyKey string `json:"topologyKey"` + // WhenUnsatisfiable indicates how to deal with a instance if it doesn't satisfy + // the spread constraint. + // - DoNotSchedule (default) tells the scheduler not to schedule it. + // - ScheduleAnyway tells the scheduler to schedule the instance in any location, + // but giving higher precedence to topologies that would help reduce the + // skew. + WhenUnsatisfiable UnsatisfiableConstraintAction `json:"whenUnsatisfiable"` + // LabelSelector is used to find matching instances. + // Instances that match this label selector are counted to determine the number of instances + // in their corresponding topology domain. + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` +} + +type InstanceStatus struct { + IPs []net.IP `json:"ips,omitempty"` + CollisionCount *int32 `json:"collisionCount,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Instance is the schema for the instances API. +type Instance struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec InstanceSpec `json:"spec,omitempty"` + Status InstanceStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InstanceList contains a list of Instance. +type InstanceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Instance `json:"items"` +} + +type InstanceTemplate struct { + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec InstanceSpec `json:"spec,omitempty"` +} diff --git a/api/core/v1alpha1/ip_types.go b/api/core/v1alpha1/ip_types.go new file mode 100644 index 00000000..4f921a81 --- /dev/null +++ b/api/core/v1alpha1/ip_types.go @@ -0,0 +1,75 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type IPType string + +const ( + IPTypePublic IPType = "Public" +) + +type IPSpec struct { + Type IPType `json:"type"` + IPFamily corev1.IPFamily `json:"ipFamily,omitempty"` + IP net.IP `json:"ip,omitempty"` + ClaimRef *IPClaimRef `json:"claimRef,omitempty"` +} + +type IPClaimRef struct { + Group string `json:"group,omitempty"` + Resource string `json:"resource,omitempty"` + Name string `json:"name,omitempty"` + UID types.UID `json:"uid,omitempty"` +} + +type IPStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// IP is the schema for the ips API. +type IP struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPSpec `json:"spec,omitempty"` + Status IPStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IPList contains a list of IP. +type IPList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IP `json:"items"` +} + +func IsIPClaimedBy(ip *IP, claimer metav1.Object) bool { + claimRef := ip.Spec.ClaimRef + if claimRef == nil { + return false + } + + return claimRef.UID == claimer.GetUID() +} diff --git a/api/core/v1alpha1/ipaddress_types.go b/api/core/v1alpha1/ipaddress_types.go new file mode 100644 index 00000000..3a1b5fe8 --- /dev/null +++ b/api/core/v1alpha1/ipaddress_types.go @@ -0,0 +1,59 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type IPAddressSpec struct { + IP net.IP `json:"ip,omitempty"` + ClaimRef IPAddressClaimRef `json:"claimRef,omitempty"` +} + +type IPAddressClaimRef struct { + Group string `json:"group,omitempty"` + Resource string `json:"resource,omitempty"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` + UID types.UID `json:"uid,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// 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"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IPAddressList contains a list of IPAddress. +type IPAddressList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPAddress `json:"items"` +} + +func IsIPAddressClaimedBy(addr *IPAddress, claimer metav1.Object) bool { + return addr.Spec.ClaimRef.UID == claimer.GetUID() +} diff --git a/api/core/v1alpha1/loadbalancer_types.go b/api/core/v1alpha1/loadbalancer_types.go new file mode 100644 index 00000000..3fbd26ab --- /dev/null +++ b/api/core/v1alpha1/loadbalancer_types.go @@ -0,0 +1,114 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type LoadBalancerType string + +const ( + LoadBalancerTypePublic LoadBalancerType = "Public" + LoadBalancerTypeInternal LoadBalancerType = "Internal" +) + +type LoadBalancerSpec struct { + // Type specifies the type of load balancer. + Type LoadBalancerType `json:"type"` + + // NetworkRef references the network the load balancer is part of. + NetworkRef corev1.LocalObjectReference `json:"networkRef"` + + // IPs specifies the IPs of the load balancer. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + IPs []LoadBalancerIP `json:"ips,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"` + + // Ports are the ports the load balancer should allow. + // If empty, the load balancer allows all ports. + Ports []LoadBalancerPort `json:"ports,omitempty"` + + // Selector selects all Instance that are managed by this daemon set. + Selector *metav1.LabelSelector `json:"nodeSelector,omitempty"` + + // Template is the instance template. + Template InstanceTemplate `json:"template"` +} + +type LoadBalancerIP struct { + // Name is the name of the load balancer IP. + Name string `json:"name"` + // IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, + // will be defaulted by using the IP family of IP. + // If only IPFamily is specified, a random IP of that family will be allocated if possible. + IPFamily corev1.IPFamily `json:"ipFamily,omitempty"` + // IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible. + IP net.IP `json:"ip,omitempty"` +} + +type LoadBalancerPort struct { + // Protocol is the protocol the load balancer should allow. + // If not specified, defaults to TCP. + Protocol *corev1.Protocol `json:"protocol,omitempty"` + // Port is the port to allow. + Port int32 `json:"port"` + // EndPort marks the end of the port range to allow. + // If unspecified, only a single port, Port, will be allowed. + EndPort *int32 `json:"endPort,omitempty"` +} + +type LoadBalancerStatus struct { + // CollisionCount is used to construct names for IP addresses for the load balancer. + CollisionCount *int32 `json:"collisionCount,omitempty"` + // IPs are the IPs used currently by the load balancer. + IPs []net.IP `json:"ips,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// LoadBalancer is the schema for the loadbalancers API. +type LoadBalancer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec LoadBalancerSpec `json:"spec,omitempty"` + Status LoadBalancerStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// LoadBalancerList contains a list of LoadBalancer. +type LoadBalancerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []LoadBalancer `json:"items"` +} + +func LoadBalancerDaemonSetName(lbName string) string { + return "lb-" + lbName +} + +func GetLoadBalancerIPs(loadBalancer *LoadBalancer) []net.IP { + res := make([]net.IP, len(loadBalancer.Spec.IPs)) + for i, ip := range loadBalancer.Spec.IPs { + res[i] = ip.IP + } + return res +} diff --git a/api/core/v1alpha1/loadbalancerrouting_types.go b/api/core/v1alpha1/loadbalancerrouting_types.go new file mode 100644 index 00000000..8351635a --- /dev/null +++ b/api/core/v1alpha1/loadbalancerrouting_types.go @@ -0,0 +1,63 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// LoadBalancerRouting is the schema for the loadbalancerroutings API. +type LoadBalancerRouting struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // IPs are the IPs the routing is for. + IPs []net.IP `json:"ips,omitempty"` + + Destinations []LoadBalancerDestination `json:"destinations,omitempty"` +} + +// LoadBalancerDestination is the destination of the load balancer. +type LoadBalancerDestination struct { + // IP is the target IP. + IP net.IP `json:"ip"` + // TargetRef is the target providing the destination. + TargetRef *LoadBalancerTargetRef `json:"targetRef,omitempty"` +} + +// LoadBalancerTargetRef is a load balancer target. +type LoadBalancerTargetRef struct { + // UID is the UID of the target. + UID types.UID `json:"uid"` + // Name is the name of the target. + Name string `json:"name"` + // NodeRef references the node the destination network interface is on. + NodeRef corev1.LocalObjectReference `json:"nodeRef"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// LoadBalancerRoutingList contains a list of LoadBalancerRouting. +type LoadBalancerRoutingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []LoadBalancerRouting `json:"items"` +} diff --git a/api/core/v1alpha1/natgateway_types.go b/api/core/v1alpha1/natgateway_types.go new file mode 100644 index 00000000..b01eb728 --- /dev/null +++ b/api/core/v1alpha1/natgateway_types.go @@ -0,0 +1,81 @@ +// Copyright 2022 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type NATGatewaySpec struct { + // IPFamily is the IP family of the NAT gateway. + IPFamily corev1.IPFamily `json:"ipFamily"` + + // NetworkRef references the network the NAT gateway is part of. + NetworkRef corev1.LocalObjectReference `json:"networkRef"` + + // IPs specifies the IPs of the NAT gateway. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + IPs []NATGatewayIP `json:"ips,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"` + + // PortsPerNetworkInterface specifies how many ports to allocate per network interface. + PortsPerNetworkInterface int32 `json:"portsPerNetworkInterface"` +} + +type NATGatewayIP struct { + // Name is the semantic name of the NAT gateway IP. + Name string `json:"name"` + // IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible. + IP net.IP `json:"ip,omitempty"` +} + +type NATGatewayStatus struct { + // UsedNATIPs is the number of NAT IPs in-use. + UsedNATIPs int64 `json:"usedNATIPs,omitempty"` + // RequestedNATIPs is the number of requested NAT IPs. + RequestedNATIPs int64 `json:"requestedNATIPs,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATGateway is the schema for the natgateways API. +type NATGateway struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NATGatewaySpec `json:"spec,omitempty"` + Status NATGatewayStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATGatewayList contains a list of NATGateway. +type NATGatewayList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NATGateway `json:"items"` +} + +func GetNATGatewayIPs(natGateway *NATGateway) []net.IP { + res := make([]net.IP, len(natGateway.Spec.IPs)) + for i, ip := range natGateway.Spec.IPs { + res[i] = ip.IP + } + return res +} diff --git a/api/core/v1alpha1/natgatewayautoscaler_types.go b/api/core/v1alpha1/natgatewayautoscaler_types.go new file mode 100644 index 00000000..731b1340 --- /dev/null +++ b/api/core/v1alpha1/natgatewayautoscaler_types.go @@ -0,0 +1,54 @@ +// Copyright 2022 OnMetal 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" +) + +type NATGatewayAutoscalerSpec struct { + // NATGatewayRef points to the target NATGateway to scale. + NATGatewayRef corev1.LocalObjectReference `json:"natGatewayRef"` + + // MinPublicIPs is the minimum number of public IPs to allocate for a NAT Gateway. + MinPublicIPs *int32 `json:"minPublicIPs,omitempty"` + // MaxPublicIPs is the maximum number of public IPs to allocate for a NAT Gateway. + MaxPublicIPs *int32 `json:"maxPublicIPs,omitempty"` +} + +type NATGatewayAutoscalerStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATGatewayAutoscaler is the schema for the natgatewayautoscalers API. +type NATGatewayAutoscaler struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NATGatewayAutoscalerSpec `json:"spec,omitempty"` + Status NATGatewayAutoscalerStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATGatewayAutoscalerList contains a list of NATGatewayAutoscaler. +type NATGatewayAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NATGatewayAutoscaler `json:"items"` +} diff --git a/api/core/v1alpha1/nattable_types.go b/api/core/v1alpha1/nattable_types.go new file mode 100644 index 00000000..15b4df3a --- /dev/null +++ b/api/core/v1alpha1/nattable_types.go @@ -0,0 +1,70 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATTable is the schema for the nattables API. +type NATTable struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // IPs specifies how to NAT the IPs for the NAT gateway. + IPs []NATIP `json:"ips,omitempty"` +} + +type NATIP struct { + // IP is the IP to NAT. + IP net.IP `json:"ip"` + // Sections are the sections of the NATIP. + Sections []NATIPSection `json:"sections,omitempty"` +} + +type NATTableIPTargetRef struct { + // UID is the UID of the target. + UID types.UID `json:"uid"` + // Name is the name of the target. + Name string `json:"name"` + // NodeRef references the node the destination network interface is on. + NodeRef corev1.LocalObjectReference `json:"nodeRef"` +} + +type NATIPSection struct { + // IP is the source IP. + IP net.IP `json:"ip"` + // Port is the start port of the section. + Port int32 `json:"port"` + // EndPort is the end port of the section + EndPort int32 `json:"endPort"` + // TargetRef references the entity having the IP. + TargetRef *NATTableIPTargetRef `json:"targetRef,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATTableList contains a list of NATTable. +type NATTableList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NATTable `json:"items"` +} diff --git a/api/core/v1alpha1/network_types.go b/api/core/v1alpha1/network_types.go new file mode 100644 index 00000000..dee98601 --- /dev/null +++ b/api/core/v1alpha1/network_types.go @@ -0,0 +1,48 @@ +// Copyright 2022 OnMetal 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" +) + +type NetworkSpec struct { + // ID is the ID of the network. + ID string `json:"id,omitempty"` +} + +type NetworkStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Network is the schema for the networks API. +type Network struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NetworkSpec `json:"spec,omitempty"` + Status NetworkStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkList contains a list of Network. +type NetworkList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Network `json:"items"` +} diff --git a/api/core/v1alpha1/networkid_types.go b/api/core/v1alpha1/networkid_types.go new file mode 100644 index 00000000..c75be8ee --- /dev/null +++ b/api/core/v1alpha1/networkid_types.go @@ -0,0 +1,57 @@ +// Copyright 2023 OnMetal 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" + "k8s.io/apimachinery/pkg/types" +) + +type NetworkIDSpec struct { + ClaimRef NetworkIDClaimRef `json:"claimRef"` +} + +type NetworkIDClaimRef struct { + Group string `json:"group,omitempty"` + Resource string `json:"resource,omitempty"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` + UID types.UID `json:"uid,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// NetworkID is the schema for the networkids API. +type NetworkID struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NetworkIDSpec `json:"spec,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkIDList contains a list of NetworkID. +type NetworkIDList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NetworkID `json:"items"` +} + +func IsNetworkIDClaimedBy(networkID *NetworkID, claimer metav1.Object) bool { + return networkID.Spec.ClaimRef.UID == claimer.GetUID() +} diff --git a/api/core/v1alpha1/networkinterface_types.go b/api/core/v1alpha1/networkinterface_types.go new file mode 100644 index 00000000..ba208ebc --- /dev/null +++ b/api/core/v1alpha1/networkinterface_types.go @@ -0,0 +1,137 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type NetworkInterfaceSpec struct { + // NodeRef is the node the network interface is hosted on. + NodeRef corev1.LocalObjectReference `json:"nodeRef"` + + // NetworkRef references the network that the network interface is in. + NetworkRef corev1.LocalObjectReference `json:"networkRef"` + + // IPs are the internal IPs of the network interface. + IPs []net.IP `json:"ips,omitempty"` + + // Prefixes are additional prefixes to route to the network interface. + Prefixes []net.IPPrefix `json:"prefixes,omitempty"` + + // NATs specify the NAT of the network interface IP family. + // Can only be set if there is no matching IP family in PublicIPs. + NATs []NetworkInterfaceNAT `json:"natGateways,omitempty"` + + // PublicIPs are the public IPs the network interface should have. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + PublicIPs []NetworkInterfacePublicIP `json:"publicIPs,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"` +} + +type NetworkInterfaceNAT struct { + // IPFamily is the IP family of the handling NAT gateway. + IPFamily corev1.IPFamily `json:"ipFamily"` + // ClaimRef references the NAT claim handling the network interface's NAT. + ClaimRef NetworkInterfaceNATClaimRef `json:"claimRef"` +} + +type NetworkInterfaceNATClaimRef struct { + // Name is the name of the claiming NAT gateway. + Name string `json:"name"` + // UID is the uid of the claiming NAT gateway. + UID types.UID `json:"uid"` +} + +type NetworkInterfacePublicIP struct { + // Name is the semantic name of the network interface public IP. + Name string `json:"name"` + // IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, + // will be defaulted by using the IP family of IP. + // If only IPFamily is specified, a random IP of that family will be allocated if possible. + IPFamily corev1.IPFamily `json:"ipFamily,omitempty"` + // IP specifies a specific IP to allocate. If empty, a random ephemeral IP will be allocated. + IP net.IP `json:"ip,omitempty"` +} + +type NetworkInterfaceState string + +const ( + // NetworkInterfaceStateReady is used for any NetworkInterface that is ready. + NetworkInterfaceStateReady NetworkInterfaceState = "Ready" + // NetworkInterfaceStatePending is used for any NetworkInterface that is in an intermediate state. + NetworkInterfaceStatePending NetworkInterfaceState = "Pending" + // NetworkInterfaceStateError is used for any NetworkInterface that is some error occurred. + NetworkInterfaceStateError NetworkInterfaceState = "Error" +) + +// PCIAddress is a PCI address. +type PCIAddress struct { + Domain string `json:"domain,omitempty"` + Bus string `json:"bus,omitempty"` + Slot string `json:"slot,omitempty"` + Function string `json:"function,omitempty"` +} + +type NetworkInterfaceStatus struct { + State NetworkInterfaceState `json:"state,omitempty"` + PCIAddress *PCIAddress `json:"pciAddress,omitempty"` + Prefixes []net.IPPrefix `json:"prefixes,omitempty"` + PublicIPs []net.IP `json:"publicIPs,omitempty"` + NATIPs []net.IP `json:"natIPs,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NetworkInterface is the schema for the networkinterfaces API. +type NetworkInterface struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NetworkInterfaceSpec `json:"spec,omitempty"` + Status NetworkInterfaceStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkInterfaceList contains a list of NetworkInterface. +type NetworkInterfaceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NetworkInterface `json:"items"` +} + +func GetNetworkInterfaceNATClaimer(nic *NetworkInterface, ipFamily corev1.IPFamily) *NetworkInterfaceNATClaimRef { + for _, nicNAT := range nic.Spec.NATs { + if nicNAT.IPFamily == ipFamily { + claimRef := nicNAT.ClaimRef + return &claimRef + } + } + return nil +} + +func GetNetworkInterfacePublicIPs(nic *NetworkInterface) []net.IP { + res := make([]net.IP, len(nic.Spec.PublicIPs)) + for i, publicIP := range nic.Spec.PublicIPs { + res[i] = publicIP.IP + } + return res +} diff --git a/api/core/v1alpha1/node_types.go b/api/core/v1alpha1/node_types.go new file mode 100644 index 00000000..894d77f0 --- /dev/null +++ b/api/core/v1alpha1/node_types.go @@ -0,0 +1,47 @@ +// Copyright 2023 OnMetal 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" +) + +type NodeSpec struct { +} + +type NodeStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// Node is the schema for the nodes API. +type Node struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NodeSpec `json:"spec,omitempty"` + Status NodeStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NodeList contains a list of Node. +type NodeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Node `json:"items"` +} diff --git a/api/core/v1alpha1/register.go b/api/core/v1alpha1/register.go new file mode 100644 index 00000000..6917e26b --- /dev/null +++ b/api/core/v1alpha1/register.go @@ -0,0 +1,74 @@ +// Copyright 2022 OnMetal 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 apinet v1alpha1 API group +// +groupName=core.apinet.api.onmetal.de +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the name of the apinet group. +const GroupName = "core.apinet.api.onmetal.de" + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, 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 +) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &DaemonSet{}, + &DaemonSetList{}, + &Instance{}, + &InstanceList{}, + &IP{}, + &IPList{}, + &IPAddress{}, + &IPAddressList{}, + &LoadBalancer{}, + &LoadBalancerList{}, + &LoadBalancerRouting{}, + &LoadBalancerRoutingList{}, + &NATGateway{}, + &NATGatewayList{}, + &NATGatewayAutoscaler{}, + &NATGatewayAutoscalerList{}, + &NATTable{}, + &NATTableList{}, + &Network{}, + &NetworkList{}, + &NetworkID{}, + &NetworkIDList{}, + &NetworkInterface{}, + &NetworkInterfaceList{}, + &Node{}, + &NodeList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/api/core/v1alpha1/well_known_annotations.go b/api/core/v1alpha1/well_known_annotations.go new file mode 100644 index 00000000..b2baca3d --- /dev/null +++ b/api/core/v1alpha1/well_known_annotations.go @@ -0,0 +1,17 @@ +// Copyright 2023 OnMetal 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 + +const () diff --git a/api/core/v1alpha1/well_known_labels.go b/api/core/v1alpha1/well_known_labels.go new file mode 100644 index 00000000..6d827cb2 --- /dev/null +++ b/api/core/v1alpha1/well_known_labels.go @@ -0,0 +1,22 @@ +// Copyright 2023 OnMetal 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 + +const ( + ControllerRevisionHashLabel = "apinet.api.onmetal.de/controller-revision-hash" + + IPFamilyLabel = "apinet.api.onmetal.de/ip-family" + IPIPLabel = "apinet.api.onmetal.de/ip" +) diff --git a/api/core/v1alpha1/zz_generated.deepcopy.go b/api/core/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..31fce754 --- /dev/null +++ b/api/core/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,1806 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * Copyright (c) 2022 by the OnMetal 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Affinity) DeepCopyInto(out *Affinity) { + *out = *in + if in.NodeAffinity != nil { + in, out := &in.NodeAffinity, &out.NodeAffinity + *out = new(NodeAffinity) + (*in).DeepCopyInto(*out) + } + if in.InstanceAntiAffinity != nil { + in, out := &in.InstanceAntiAffinity, &out.InstanceAntiAffinity + *out = new(InstanceAntiAffinity) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Affinity. +func (in *Affinity) DeepCopy() *Affinity { + if in == nil { + return nil + } + out := new(Affinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonSet) DeepCopyInto(out *DaemonSet) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSet. +func (in *DaemonSet) DeepCopy() *DaemonSet { + if in == nil { + return nil + } + out := new(DaemonSet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DaemonSet) 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 *DaemonSetList) DeepCopyInto(out *DaemonSetList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DaemonSet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetList. +func (in *DaemonSetList) DeepCopy() *DaemonSetList { + if in == nil { + return nil + } + out := new(DaemonSetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DaemonSetList) 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 *DaemonSetSpec) DeepCopyInto(out *DaemonSetSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetSpec. +func (in *DaemonSetSpec) DeepCopy() *DaemonSetSpec { + if in == nil { + return nil + } + out := new(DaemonSetSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonSetStatus) DeepCopyInto(out *DaemonSetStatus) { + *out = *in + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetStatus. +func (in *DaemonSetStatus) DeepCopy() *DaemonSetStatus { + if in == nil { + return nil + } + out := new(DaemonSetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IP) DeepCopyInto(out *IP) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IP. +func (in *IP) DeepCopy() *IP { + if in == nil { + return nil + } + out := new(IP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IP) 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 *IPAddress) DeepCopyInto(out *IPAddress) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// 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 *IPAddressClaimRef) DeepCopyInto(out *IPAddressClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressClaimRef. +func (in *IPAddressClaimRef) DeepCopy() *IPAddressClaimRef { + if in == nil { + return nil + } + out := new(IPAddressClaimRef) + in.DeepCopyInto(out) + return out +} + +// 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]) + } + } + return +} + +// 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 + in.IP.DeepCopyInto(&out.IP) + out.ClaimRef = in.ClaimRef + return +} + +// 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 *IPClaimRef) DeepCopyInto(out *IPClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimRef. +func (in *IPClaimRef) DeepCopy() *IPClaimRef { + if in == nil { + return nil + } + out := new(IPClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPList) DeepCopyInto(out *IPList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPList. +func (in *IPList) DeepCopy() *IPList { + if in == nil { + return nil + } + out := new(IPList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPList) 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 *IPSpec) DeepCopyInto(out *IPSpec) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.ClaimRef != nil { + in, out := &in.ClaimRef, &out.ClaimRef + *out = new(IPClaimRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPSpec. +func (in *IPSpec) DeepCopy() *IPSpec { + if in == nil { + return nil + } + out := new(IPSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPStatus) DeepCopyInto(out *IPStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPStatus. +func (in *IPStatus) DeepCopy() *IPStatus { + if in == nil { + return nil + } + out := new(IPStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Instance) DeepCopyInto(out *Instance) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instance. +func (in *Instance) DeepCopy() *Instance { + if in == nil { + return nil + } + out := new(Instance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Instance) 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 *InstanceAffinityTerm) DeepCopyInto(out *InstanceAffinityTerm) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceAffinityTerm. +func (in *InstanceAffinityTerm) DeepCopy() *InstanceAffinityTerm { + if in == nil { + return nil + } + out := new(InstanceAffinityTerm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceAntiAffinity) DeepCopyInto(out *InstanceAntiAffinity) { + *out = *in + if in.RequiredDuringSchedulingIgnoredDuringExecution != nil { + in, out := &in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution + *out = make([]InstanceAffinityTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceAntiAffinity. +func (in *InstanceAntiAffinity) DeepCopy() *InstanceAntiAffinity { + if in == nil { + return nil + } + out := new(InstanceAntiAffinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceList) DeepCopyInto(out *InstanceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Instance, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceList. +func (in *InstanceList) DeepCopy() *InstanceList { + if in == nil { + return nil + } + out := new(InstanceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstanceList) 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 *InstanceSpec) DeepCopyInto(out *InstanceSpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LoadBalancerPorts != nil { + in, out := &in.LoadBalancerPorts, &out.LoadBalancerPorts + *out = make([]LoadBalancerPort, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(Affinity) + (*in).DeepCopyInto(*out) + } + if in.TopologySpreadConstraints != nil { + in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints + *out = make([]TopologySpreadConstraint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NodeRef != nil { + in, out := &in.NodeRef, &out.NodeRef + *out = new(corev1.LocalObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. +func (in *InstanceSpec) DeepCopy() *InstanceSpec { + if in == nil { + return nil + } + out := new(InstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { + *out = *in + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. +func (in *InstanceStatus) DeepCopy() *InstanceStatus { + if in == nil { + return nil + } + out := new(InstanceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceTemplate) DeepCopyInto(out *InstanceTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceTemplate. +func (in *InstanceTemplate) DeepCopy() *InstanceTemplate { + if in == nil { + return nil + } + out := new(InstanceTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancer) DeepCopyInto(out *LoadBalancer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancer. +func (in *LoadBalancer) DeepCopy() *LoadBalancer { + if in == nil { + return nil + } + out := new(LoadBalancer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancer) 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 *LoadBalancerDestination) DeepCopyInto(out *LoadBalancerDestination) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.TargetRef != nil { + in, out := &in.TargetRef, &out.TargetRef + *out = new(LoadBalancerTargetRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerDestination. +func (in *LoadBalancerDestination) DeepCopy() *LoadBalancerDestination { + if in == nil { + return nil + } + out := new(LoadBalancerDestination) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerIP) DeepCopyInto(out *LoadBalancerIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerIP. +func (in *LoadBalancerIP) DeepCopy() *LoadBalancerIP { + if in == nil { + return nil + } + out := new(LoadBalancerIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerList) DeepCopyInto(out *LoadBalancerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]LoadBalancer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerList. +func (in *LoadBalancerList) DeepCopy() *LoadBalancerList { + if in == nil { + return nil + } + out := new(LoadBalancerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerList) 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 *LoadBalancerPort) DeepCopyInto(out *LoadBalancerPort) { + *out = *in + if in.Protocol != nil { + in, out := &in.Protocol, &out.Protocol + *out = new(corev1.Protocol) + **out = **in + } + if in.EndPort != nil { + in, out := &in.EndPort, &out.EndPort + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerPort. +func (in *LoadBalancerPort) DeepCopy() *LoadBalancerPort { + if in == nil { + return nil + } + out := new(LoadBalancerPort) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerRouting) DeepCopyInto(out *LoadBalancerRouting) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Destinations != nil { + in, out := &in.Destinations, &out.Destinations + *out = make([]LoadBalancerDestination, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerRouting. +func (in *LoadBalancerRouting) DeepCopy() *LoadBalancerRouting { + if in == nil { + return nil + } + out := new(LoadBalancerRouting) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerRouting) 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 *LoadBalancerRoutingList) DeepCopyInto(out *LoadBalancerRoutingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]LoadBalancerRouting, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerRoutingList. +func (in *LoadBalancerRoutingList) DeepCopy() *LoadBalancerRoutingList { + if in == nil { + return nil + } + out := new(LoadBalancerRoutingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerRoutingList) 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 *LoadBalancerSpec) DeepCopyInto(out *LoadBalancerSpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]LoadBalancerIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Ports != nil { + in, out := &in.Ports, &out.Ports + *out = make([]LoadBalancerPort, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerSpec. +func (in *LoadBalancerSpec) DeepCopy() *LoadBalancerSpec { + if in == nil { + return nil + } + out := new(LoadBalancerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerStatus) DeepCopyInto(out *LoadBalancerStatus) { + *out = *in + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerStatus. +func (in *LoadBalancerStatus) DeepCopy() *LoadBalancerStatus { + if in == nil { + return nil + } + out := new(LoadBalancerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerTargetRef) DeepCopyInto(out *LoadBalancerTargetRef) { + *out = *in + out.NodeRef = in.NodeRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerTargetRef. +func (in *LoadBalancerTargetRef) DeepCopy() *LoadBalancerTargetRef { + if in == nil { + return nil + } + out := new(LoadBalancerTargetRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGateway) DeepCopyInto(out *NATGateway) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGateway. +func (in *NATGateway) DeepCopy() *NATGateway { + if in == nil { + return nil + } + out := new(NATGateway) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGateway) 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 *NATGatewayAutoscaler) DeepCopyInto(out *NATGatewayAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscaler. +func (in *NATGatewayAutoscaler) DeepCopy() *NATGatewayAutoscaler { + if in == nil { + return nil + } + out := new(NATGatewayAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayAutoscaler) 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 *NATGatewayAutoscalerList) DeepCopyInto(out *NATGatewayAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATGatewayAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerList. +func (in *NATGatewayAutoscalerList) DeepCopy() *NATGatewayAutoscalerList { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayAutoscalerList) 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 *NATGatewayAutoscalerSpec) DeepCopyInto(out *NATGatewayAutoscalerSpec) { + *out = *in + out.NATGatewayRef = in.NATGatewayRef + if in.MinPublicIPs != nil { + in, out := &in.MinPublicIPs, &out.MinPublicIPs + *out = new(int32) + **out = **in + } + if in.MaxPublicIPs != nil { + in, out := &in.MaxPublicIPs, &out.MaxPublicIPs + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerSpec. +func (in *NATGatewayAutoscalerSpec) DeepCopy() *NATGatewayAutoscalerSpec { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayAutoscalerStatus) DeepCopyInto(out *NATGatewayAutoscalerStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerStatus. +func (in *NATGatewayAutoscalerStatus) DeepCopy() *NATGatewayAutoscalerStatus { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayIP) DeepCopyInto(out *NATGatewayIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayIP. +func (in *NATGatewayIP) DeepCopy() *NATGatewayIP { + if in == nil { + return nil + } + out := new(NATGatewayIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayList) DeepCopyInto(out *NATGatewayList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATGateway, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayList. +func (in *NATGatewayList) DeepCopy() *NATGatewayList { + if in == nil { + return nil + } + out := new(NATGatewayList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayList) 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 *NATGatewaySpec) DeepCopyInto(out *NATGatewaySpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]NATGatewayIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewaySpec. +func (in *NATGatewaySpec) DeepCopy() *NATGatewaySpec { + if in == nil { + return nil + } + out := new(NATGatewaySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayStatus) DeepCopyInto(out *NATGatewayStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayStatus. +func (in *NATGatewayStatus) DeepCopy() *NATGatewayStatus { + if in == nil { + return nil + } + out := new(NATGatewayStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATIP) DeepCopyInto(out *NATIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.Sections != nil { + in, out := &in.Sections, &out.Sections + *out = make([]NATIPSection, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATIP. +func (in *NATIP) DeepCopy() *NATIP { + if in == nil { + return nil + } + out := new(NATIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATIPSection) DeepCopyInto(out *NATIPSection) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.TargetRef != nil { + in, out := &in.TargetRef, &out.TargetRef + *out = new(NATTableIPTargetRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATIPSection. +func (in *NATIPSection) DeepCopy() *NATIPSection { + if in == nil { + return nil + } + out := new(NATIPSection) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATTable) DeepCopyInto(out *NATTable) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]NATIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTable. +func (in *NATTable) DeepCopy() *NATTable { + if in == nil { + return nil + } + out := new(NATTable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATTable) 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 *NATTableIPTargetRef) DeepCopyInto(out *NATTableIPTargetRef) { + *out = *in + out.NodeRef = in.NodeRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTableIPTargetRef. +func (in *NATTableIPTargetRef) DeepCopy() *NATTableIPTargetRef { + if in == nil { + return nil + } + out := new(NATTableIPTargetRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATTableList) DeepCopyInto(out *NATTableList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATTable, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTableList. +func (in *NATTableList) DeepCopy() *NATTableList { + if in == nil { + return nil + } + out := new(NATTableList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATTableList) 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 *Network) DeepCopyInto(out *Network) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Network. +func (in *Network) DeepCopy() *Network { + if in == nil { + return nil + } + out := new(Network) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Network) 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 *NetworkID) DeepCopyInto(out *NetworkID) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkID. +func (in *NetworkID) DeepCopy() *NetworkID { + if in == nil { + return nil + } + out := new(NetworkID) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkID) 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 *NetworkIDClaimRef) DeepCopyInto(out *NetworkIDClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDClaimRef. +func (in *NetworkIDClaimRef) DeepCopy() *NetworkIDClaimRef { + if in == nil { + return nil + } + out := new(NetworkIDClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkIDList) DeepCopyInto(out *NetworkIDList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NetworkID, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDList. +func (in *NetworkIDList) DeepCopy() *NetworkIDList { + if in == nil { + return nil + } + out := new(NetworkIDList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkIDList) 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 *NetworkIDSpec) DeepCopyInto(out *NetworkIDSpec) { + *out = *in + out.ClaimRef = in.ClaimRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDSpec. +func (in *NetworkIDSpec) DeepCopy() *NetworkIDSpec { + if in == nil { + return nil + } + out := new(NetworkIDSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterface) DeepCopyInto(out *NetworkInterface) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterface. +func (in *NetworkInterface) DeepCopy() *NetworkInterface { + if in == nil { + return nil + } + out := new(NetworkInterface) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkInterface) 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 *NetworkInterfaceList) DeepCopyInto(out *NetworkInterfaceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NetworkInterface, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceList. +func (in *NetworkInterfaceList) DeepCopy() *NetworkInterfaceList { + if in == nil { + return nil + } + out := new(NetworkInterfaceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkInterfaceList) 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 *NetworkInterfaceNAT) DeepCopyInto(out *NetworkInterfaceNAT) { + *out = *in + out.ClaimRef = in.ClaimRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceNAT. +func (in *NetworkInterfaceNAT) DeepCopy() *NetworkInterfaceNAT { + if in == nil { + return nil + } + out := new(NetworkInterfaceNAT) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceNATClaimRef) DeepCopyInto(out *NetworkInterfaceNATClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceNATClaimRef. +func (in *NetworkInterfaceNATClaimRef) DeepCopy() *NetworkInterfaceNATClaimRef { + if in == nil { + return nil + } + out := new(NetworkInterfaceNATClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfacePublicIP) DeepCopyInto(out *NetworkInterfacePublicIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfacePublicIP. +func (in *NetworkInterfacePublicIP) DeepCopy() *NetworkInterfacePublicIP { + if in == nil { + return nil + } + out := new(NetworkInterfacePublicIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceSpec) DeepCopyInto(out *NetworkInterfaceSpec) { + *out = *in + out.NodeRef = in.NodeRef + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Prefixes != nil { + in, out := &in.Prefixes, &out.Prefixes + *out = make([]net.IPPrefix, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NATs != nil { + in, out := &in.NATs, &out.NATs + *out = make([]NetworkInterfaceNAT, len(*in)) + copy(*out, *in) + } + if in.PublicIPs != nil { + in, out := &in.PublicIPs, &out.PublicIPs + *out = make([]NetworkInterfacePublicIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceSpec. +func (in *NetworkInterfaceSpec) DeepCopy() *NetworkInterfaceSpec { + if in == nil { + return nil + } + out := new(NetworkInterfaceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceStatus) DeepCopyInto(out *NetworkInterfaceStatus) { + *out = *in + if in.PCIAddress != nil { + in, out := &in.PCIAddress, &out.PCIAddress + *out = new(PCIAddress) + **out = **in + } + if in.Prefixes != nil { + in, out := &in.Prefixes, &out.Prefixes + *out = make([]net.IPPrefix, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PublicIPs != nil { + in, out := &in.PublicIPs, &out.PublicIPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NATIPs != nil { + in, out := &in.NATIPs, &out.NATIPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceStatus. +func (in *NetworkInterfaceStatus) DeepCopy() *NetworkInterfaceStatus { + if in == nil { + return nil + } + out := new(NetworkInterfaceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkList) DeepCopyInto(out *NetworkList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Network, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkList. +func (in *NetworkList) DeepCopy() *NetworkList { + if in == nil { + return nil + } + out := new(NetworkList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkList) 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 *NetworkSpec) DeepCopyInto(out *NetworkSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. +func (in *NetworkSpec) DeepCopy() *NetworkSpec { + if in == nil { + return nil + } + out := new(NetworkSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. +func (in *NetworkStatus) DeepCopy() *NetworkStatus { + if in == nil { + return nil + } + out := new(NetworkStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Node) DeepCopyInto(out *Node) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node. +func (in *Node) DeepCopy() *Node { + if in == nil { + return nil + } + out := new(Node) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Node) 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 *NodeAffinity) DeepCopyInto(out *NodeAffinity) { + *out = *in + if in.RequiredDuringSchedulingIgnoredDuringExecution != nil { + in, out := &in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution + *out = new(NodeSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeAffinity. +func (in *NodeAffinity) DeepCopy() *NodeAffinity { + if in == nil { + return nil + } + out := new(NodeAffinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeList) DeepCopyInto(out *NodeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Node, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeList. +func (in *NodeList) DeepCopy() *NodeList { + if in == nil { + return nil + } + out := new(NodeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeList) 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 *NodeSelector) DeepCopyInto(out *NodeSelector) { + *out = *in + if in.NodeSelectorTerms != nil { + in, out := &in.NodeSelectorTerms, &out.NodeSelectorTerms + *out = make([]NodeSelectorTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelector. +func (in *NodeSelector) DeepCopy() *NodeSelector { + if in == nil { + return nil + } + out := new(NodeSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSelectorRequirement) DeepCopyInto(out *NodeSelectorRequirement) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelectorRequirement. +func (in *NodeSelectorRequirement) DeepCopy() *NodeSelectorRequirement { + if in == nil { + return nil + } + out := new(NodeSelectorRequirement) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSelectorTerm) DeepCopyInto(out *NodeSelectorTerm) { + *out = *in + if in.MatchExpressions != nil { + in, out := &in.MatchExpressions, &out.MatchExpressions + *out = make([]NodeSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.MatchFields != nil { + in, out := &in.MatchFields, &out.MatchFields + *out = make([]NodeSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelectorTerm. +func (in *NodeSelectorTerm) DeepCopy() *NodeSelectorTerm { + if in == nil { + return nil + } + out := new(NodeSelectorTerm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSpec. +func (in *NodeSpec) DeepCopy() *NodeSpec { + if in == nil { + return nil + } + out := new(NodeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatus) DeepCopyInto(out *NodeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatus. +func (in *NodeStatus) DeepCopy() *NodeStatus { + if in == nil { + return nil + } + out := new(NodeStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PCIAddress) DeepCopyInto(out *PCIAddress) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PCIAddress. +func (in *PCIAddress) DeepCopy() *PCIAddress { + if in == nil { + return nil + } + out := new(PCIAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TopologySpreadConstraint) DeepCopyInto(out *TopologySpreadConstraint) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopologySpreadConstraint. +func (in *TopologySpreadConstraint) DeepCopy() *TopologySpreadConstraint { + if in == nil { + return nil + } + out := new(TopologySpreadConstraint) + in.DeepCopyInto(out) + return out +} diff --git a/api/v1alpha1/network_types.go b/api/v1alpha1/network_types.go deleted file mode 100644 index a5a8f30f..00000000 --- a/api/v1alpha1/network_types.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 OnMetal 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" -) - -type NetworkSpec struct { - // +kubebuilder:validation:Maximum=16777215 - // +kubebuilder:validation:Minimum=0 - // VNI is the requested network vni. - // Pointer to distinguish between explicitly set and unset. - VNI *int32 `json:"vni,omitempty"` -} - -type NetworkConditionType string - -const ( - NetworkAllocated NetworkConditionType = "Allocated" -) - -type NetworkCondition struct { - Type NetworkConditionType `json:"type"` - Status corev1.ConditionStatus `json:"status"` - Reason string `json:"reason,omitempty"` - Message string `json:"message,omitempty"` -} - -func NetworkConditionIndex(conditions []NetworkCondition, conditionType NetworkConditionType) int { - for i, condition := range conditions { - if condition.Type == conditionType { - return i - } - } - return -1 -} - -func SetNetworkCondition(conditions *[]NetworkCondition, condition NetworkCondition) { - if idx := NetworkConditionIndex(*conditions, condition.Type); idx != -1 { - (*conditions)[idx] = condition - } else { - *conditions = append(*conditions, condition) - } -} - -type NetworkStatus struct { - // Conditions are the conditions of a network. - Conditions []NetworkCondition `json:"conditions,omitempty"` -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:printcolumn:name="VNI",type=string,JSONPath=`.spec.vni` -// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.conditions[?(@.type == "Allocated")].reason` -// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp" - -// Network is the schema for the publicips API. -type Network struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec NetworkSpec `json:"spec,omitempty"` - Status NetworkStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// NetworkList contains a list of Network. -type NetworkList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Network `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Network{}, &NetworkList{}) -} diff --git a/api/v1alpha1/publicip_types.go b/api/v1alpha1/publicip_types.go deleted file mode 100644 index d8fac1ed..00000000 --- a/api/v1alpha1/publicip_types.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2022 OnMetal 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" -) - -type PublicIPSpec struct { - // IPFamily is the ip family of the public ip. - IPFamily corev1.IPFamily `json:"ipFamily"` - // IP is the ip of the public IP. - // Pointer to distinguish between unset and explicit zero. - IP *IP `json:"ip,omitempty"` -} - -type PublicIPConditionType string - -const ( - PublicIPAllocated PublicIPConditionType = "Allocated" -) - -type PublicIPCondition struct { - Type PublicIPConditionType `json:"type"` - Status corev1.ConditionStatus `json:"status"` - Reason string `json:"reason,omitempty"` - Message string `json:"message,omitempty"` -} - -func PublicIPConditionIndex(conditions []PublicIPCondition, conditionType PublicIPConditionType) int { - for i, condition := range conditions { - if condition.Type == conditionType { - return i - } - } - return -1 -} - -func SetPublicIPCondition(conditions *[]PublicIPCondition, condition PublicIPCondition) { - if idx := PublicIPConditionIndex(*conditions, condition.Type); idx != -1 { - (*conditions)[idx] = condition - } else { - *conditions = append(*conditions, condition) - } -} - -type PublicIPStatus struct { - // Conditions are the conditions of a PublicIP. - Conditions []PublicIPCondition `json:"conditions,omitempty"` -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:printcolumn:name="IPFamily",type=string,JSONPath=`.spec.ipFamily` -// +kubebuilder:printcolumn:name="IP",type=string,JSONPath=`.spec.ip` -// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.conditions[?(@.type == "Allocated")].reason` -// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp" - -// PublicIP is the schema for the publicips API. -type PublicIP struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec PublicIPSpec `json:"spec,omitempty"` - Status PublicIPStatus `json:"status,omitempty"` -} - -func (ip *PublicIP) IsAllocated() bool { - apiNetPublicIPConditions := ip.Status.Conditions - idx := PublicIPConditionIndex(ip.Status.Conditions, PublicIPAllocated) - if idx < 0 || apiNetPublicIPConditions[idx].Status != corev1.ConditionTrue { - return false - } - - return ip.Spec.IP.IsValid() -} - -// +kubebuilder:object:root=true - -// PublicIPList contains a list of PublicIP. -type PublicIPList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []PublicIP `json:"items"` -} - -func init() { - SchemeBuilder.Register(&PublicIP{}, &PublicIPList{}) -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 9cb26048..00000000 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,253 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * Copyright (c) 2022 by the OnMetal 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 ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Network) DeepCopyInto(out *Network) { - *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 Network. -func (in *Network) DeepCopy() *Network { - if in == nil { - return nil - } - out := new(Network) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Network) 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 *NetworkCondition) DeepCopyInto(out *NetworkCondition) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkCondition. -func (in *NetworkCondition) DeepCopy() *NetworkCondition { - if in == nil { - return nil - } - out := new(NetworkCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkList) DeepCopyInto(out *NetworkList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Network, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkList. -func (in *NetworkList) DeepCopy() *NetworkList { - if in == nil { - return nil - } - out := new(NetworkList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *NetworkList) 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 *NetworkSpec) DeepCopyInto(out *NetworkSpec) { - *out = *in - if in.VNI != nil { - in, out := &in.VNI, &out.VNI - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. -func (in *NetworkSpec) DeepCopy() *NetworkSpec { - if in == nil { - return nil - } - out := new(NetworkSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]NetworkCondition, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. -func (in *NetworkStatus) DeepCopy() *NetworkStatus { - if in == nil { - return nil - } - out := new(NetworkStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PublicIP) DeepCopyInto(out *PublicIP) { - *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 PublicIP. -func (in *PublicIP) DeepCopy() *PublicIP { - if in == nil { - return nil - } - out := new(PublicIP) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *PublicIP) 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 *PublicIPCondition) DeepCopyInto(out *PublicIPCondition) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PublicIPCondition. -func (in *PublicIPCondition) DeepCopy() *PublicIPCondition { - if in == nil { - return nil - } - out := new(PublicIPCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PublicIPList) DeepCopyInto(out *PublicIPList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]PublicIP, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PublicIPList. -func (in *PublicIPList) DeepCopy() *PublicIPList { - if in == nil { - return nil - } - out := new(PublicIPList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *PublicIPList) 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 *PublicIPSpec) DeepCopyInto(out *PublicIPSpec) { - *out = *in - if in.IP != nil { - in, out := &in.IP, &out.IP - *out = (*in).DeepCopy() - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PublicIPSpec. -func (in *PublicIPSpec) DeepCopy() *PublicIPSpec { - if in == nil { - return nil - } - out := new(PublicIPSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PublicIPStatus) DeepCopyInto(out *PublicIPStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]PublicIPCondition, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PublicIPStatus. -func (in *PublicIPStatus) DeepCopy() *PublicIPStatus { - if in == nil { - return nil - } - out := new(PublicIPStatus) - in.DeepCopyInto(out) - return out -} diff --git a/api/v1alpha1/common_types.go b/apimachinery/api/net/net.go similarity index 50% rename from api/v1alpha1/common_types.go rename to apimachinery/api/net/net.go index 7f5e3c2f..e0b70f6d 100644 --- a/api/v1alpha1/common_types.go +++ b/apimachinery/api/net/net.go @@ -1,4 +1,4 @@ -// Copyright 2022 OnMetal authors +// Copyright 2023 OnMetal authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,44 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package net import ( "encoding/json" "net/netip" - corev1 "k8s.io/api/core/v1" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/runtime" ) -const ( - ReconcileRequestAnnotation = "reconcile.apinet.api.onmetal.de/requestedAt" - - // APINetletsGroup is the system rbac group all apinetlets are in. - APINetletsGroup = "apinet.api.onmetal.de:system:apinetlets" - - // APINetletUserNamePrefix is the prefix all apinetlet users should have. - APINetletUserNamePrefix = "apinet.api.onmetal.de:system:apinetlet:" - - // MetalnetletsGroup is the system rbac group all metalnetlets are in. - MetalnetletsGroup = "apinet.api.onmetal.de:system:metalnetlets" - - // MetalnetletUserNamePrefix is the prefix all metalnetlet users should have. - MetalnetletUserNamePrefix = "apinet.api.onmetal.de:system:metalnetlet:" -) - -// APINetletCommonName constructs the common name for a certificate of an apinetlet user. -func APINetletCommonName(name string) string { - return APINetletUserNamePrefix + name -} - -// MetalnetletCommonName constructs the common name for a certificate of a metalnetlet user. -func MetalnetletCommonName(name string) string { - return MetalnetletUserNamePrefix + name -} - // IP is an IP address. -// +kubebuilder:validation:Type=string +// +k8s:openapi-gen=true type IP struct { netip.Addr `json:"-"` } @@ -110,12 +84,12 @@ func (i *IP) IsZero() bool { return i == nil || !i.Addr.IsValid() } -func (i IP) Family() corev1.IPFamily { +func (i IP) Family() v1.IPFamily { switch { case i.Is4(): - return corev1.IPv4Protocol + return v1.IPv4Protocol case i.Is6(): - return corev1.IPv6Protocol + return v1.IPv6Protocol default: return "" } @@ -151,7 +125,7 @@ func MustParseIP(s string) IP { func MustParseNewIP(s string) *IP { ip, err := ParseNewIP(s) - utilruntime.Must(err) + runtime.Must(err) return ip } @@ -162,3 +136,112 @@ func NewIPPtr(ip netip.Addr) *IP { func PtrToIP(addr IP) *IP { return &addr } + +// IPPrefix represents a network prefix. +// +k8s:openapi-gen=true +// +nullable +type IPPrefix struct { + netip.Prefix `json:"-"` +} + +func (i IPPrefix) GomegaString() string { + return i.String() +} + +func (i IPPrefix) IP() IP { + return IP{i.Prefix.Addr()} +} + +func (i *IPPrefix) UnmarshalJSON(b []byte) error { + if len(b) == 4 && string(b) == "null" { + i.Prefix = netip.Prefix{} + return nil + } + + var str string + err := json.Unmarshal(b, &str) + if err != nil { + return err + } + + p, err := netip.ParsePrefix(str) + if err != nil { + return err + } + + i.Prefix = p + return nil +} + +func (i IPPrefix) MarshalJSON() ([]byte, error) { + if i.IsZero() { + // Encode unset/nil objects as JSON's "null". + return []byte("null"), nil + } + return json.Marshal(i.String()) +} + +func (i IPPrefix) ToUnstructured() interface{} { + if i.IsZero() { + return nil + } + return i.String() +} + +func (in *IPPrefix) DeepCopyInto(out *IPPrefix) { + *out = *in +} + +func (in *IPPrefix) DeepCopy() *IPPrefix { + return &IPPrefix{in.Prefix} +} + +func (in *IPPrefix) IsValid() bool { + return in != nil && in.Prefix.IsValid() +} + +func (in *IPPrefix) IsZero() bool { + return in == nil || !in.Prefix.IsValid() +} + +func (_ IPPrefix) OpenAPISchemaType() []string { return []string{"string"} } + +func (_ IPPrefix) OpenAPISchemaFormat() string { return "ip-prefix" } + +func NewIPPrefix(prefix netip.Prefix) *IPPrefix { + return &IPPrefix{Prefix: prefix} +} + +func ParseIPPrefix(s string) (IPPrefix, error) { + prefix, err := netip.ParsePrefix(s) + if err != nil { + return IPPrefix{}, err + } + return IPPrefix{prefix}, nil +} + +func ParseNewIPPrefix(s string) (*IPPrefix, error) { + prefix, err := ParseIPPrefix(s) + if err != nil { + return nil, err + } + return &prefix, nil +} + +func MustParseIPPrefix(s string) IPPrefix { + return IPPrefix{netip.MustParsePrefix(s)} +} + +func MustParseNewIPPrefix(s string) *IPPrefix { + prefix, err := ParseNewIPPrefix(s) + runtime.Must(err) + return prefix +} + +func PtrToIPPrefix(prefix IPPrefix) *IPPrefix { + return &prefix +} + +func EqualIPPrefixes(a, b IPPrefix) bool { + return a == b +} diff --git a/apimachinery/equality/semantic.go b/apimachinery/equality/semantic.go new file mode 100644 index 00000000..41757db9 --- /dev/null +++ b/apimachinery/equality/semantic.go @@ -0,0 +1,47 @@ +// Copyright 2023 OnMetal 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 equality + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/conversion" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/third_party/forked/golang/reflect" +) + +// Semantic checks whether onmetal types are semantically equal. +// It uses equality.Semantic as baseline and adds custom functions on top. +var Semantic conversion.Equalities + +func init() { + base := make(reflect.Equalities) + for k, v := range equality.Semantic.Equalities { + base[k] = v + } + Semantic = conversion.Equalities{Equalities: base} + utilruntime.Must(AddFuncs(Semantic)) +} + +func AddFuncs(equality conversion.Equalities) error { + return equality.AddFuncs( + func(a, b net.IP) bool { + return a == b + }, + func(a, b net.IPPrefix) bool { + return a == b + }, + ) +} diff --git a/apinetlet/api/v1alpha1/common_types.go b/apinetlet/api/v1alpha1/common_types.go index febed732..e01b39a1 100644 --- a/apinetlet/api/v1alpha1/common_types.go +++ b/apinetlet/api/v1alpha1/common_types.go @@ -14,22 +14,19 @@ package v1alpha1 -const ( - NetworkUIDLabel = "apinetlet.api.onmetal.de/network-uid" - NetworkNamespaceLabel = "apinetlet.api.onmetal.de/network-namespace" - NetworkNameLabel = "apinetlet.api.onmetal.de/network-name" - - VirtualIPUIDLabel = "apinetlet.api.onmetal.de/virtualip-uid" - VirtualIPNamespaceLabel = "apinetlet.api.onmetal.de/virtualip-namespace" - VirtualIPNameLabel = "apinetlet.api.onmetal.de/virtualip-name" +import ( + "fmt" + "strings" +) - NATGatewayUIDLabel = "apinetlet.api.onmetal.de/natgateway-uid" - NATGatewayNamespaceLabel = "apinetlet.api.onmetal.de/natgateway-namespace" - NATGatewayNameLabel = "apinetlet.api.onmetal.de/natgateway-name" +func SourceNameLabel(kind string) string { + return fmt.Sprintf("apinetlet.api.onmetal.de/%s-name", strings.ToLower(kind)) +} - LoadBalancerUIDLabel = "apinetlet.api.onmetal.de/loadbalancer-uid" - LoadBalancerNamespaceLabel = "apinetlet.api.onmetal.de/loadbalancer-namespace" - LoadBalancerNameLabel = "apinetlet.api.onmetal.de/loadbalancer-name" +func SourceNamespaceLabel(kind string) string { + return fmt.Sprintf("apinetlet.api.onmetal.de/%s-namespace", strings.ToLower(kind)) +} - FieldOwner = "apinetlet.api.onmetal.de/field-owner" -) +func SourceUIDLabel(kind string) string { + return fmt.Sprintf("apinetlet.api.onmetal.de/%s-uid", strings.ToLower(kind)) +} diff --git a/onmetal-api-net/controllers/events.go b/apinetlet/client/client.go similarity index 79% rename from onmetal-api-net/controllers/events.go rename to apinetlet/client/client.go index d82326be..08d00845 100644 --- a/onmetal-api-net/controllers/events.go +++ b/apinetlet/client/client.go @@ -1,4 +1,4 @@ -// Copyright 2022 OnMetal authors +// Copyright 2023 OnMetal authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -package controllers +package client const ( - FailedAllocatingNetwork = "FailedAllocating" - FailedAllocatingPublicIP = "FailedAllocating" + NetworkInterfaceProviderIDField = ".status.providerID" ) diff --git a/apinetlet/client/config/getter.go b/apinetlet/client/config/getter.go index be3916e2..5bb48d35 100644 --- a/apinetlet/client/config/getter.go +++ b/apinetlet/client/config/getter.go @@ -19,7 +19,7 @@ import ( "crypto/x509/pkix" "os" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" utilcertificate "github.com/onmetal/onmetal-api/utils/certificate" "github.com/onmetal/onmetal-api/utils/client/config" diff --git a/apinetlet/client/sourceaware.go b/apinetlet/client/sourceaware.go new file mode 100644 index 00000000..75c949c6 --- /dev/null +++ b/apinetlet/client/sourceaware.go @@ -0,0 +1,58 @@ +// Copyright 2023 OnMetal 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 client + +import ( + utilapi "github.com/onmetal/onmetal-api-net/utils/api" + utilclient "github.com/onmetal/onmetal-api-net/utils/client" +) + +var ( + SourceAwareSystem = utilclient.NewSourceAwareSystem(utilapi.PrefixSourceAwareSystem("apinetlet.api.onmetal.de/")) + + SourceLabelKeysE = SourceAwareSystem.SourceLabelKeysE + + SourceLabelKeys = SourceAwareSystem.SourceLabelKeys + + SourceLabelsE = SourceAwareSystem.SourceLabelsE + + SourceLabels = SourceAwareSystem.SourceLabels + + MatchingSourceLabelsE = SourceAwareSystem.MatchingSourceLabelsE + + MatchingSourceLabels = SourceAwareSystem.MatchingSourceLabels + + HasSourceLabelsE = SourceAwareSystem.HasSourceLabelsE + + HasSourceLabels = SourceAwareSystem.HasSourceLabels + + SourceKeyLabelsE = SourceAwareSystem.SourceKeyLabelsE + + SourceKeyLabels = SourceAwareSystem.SourceKeyLabels + + MatchingSourceKeyLabelsE = SourceAwareSystem.MatchingSourceKeyLabelsE + + MatchingSourceKeyLabels = SourceAwareSystem.MatchingSourceKeyLabels + + SourceObjectKeyFromObjectE = SourceAwareSystem.SourceObjectKeyFromObjectE + + SourceObjectKeyFromObject = SourceAwareSystem.SourceObjectKeyFromObject + + SourceObjectDataFromObjectE = SourceAwareSystem.SourceObjectDataFromObjectE + + SourceObjectDataFromObject = SourceAwareSystem.SourceObjectDataFromObject +) + +type SourceObjectData = utilclient.SourceObjectData diff --git a/apinetlet/controllers/controllers_suite_test.go b/apinetlet/controllers/controllers_suite_test.go index 62bfc4fa..2d5f4533 100644 --- a/apinetlet/controllers/controllers_suite_test.go +++ b/apinetlet/controllers/controllers_suite_test.go @@ -24,14 +24,15 @@ import ( "github.com/onmetal/controller-utils/buildutils" "github.com/onmetal/controller-utils/modutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" envtestutils "github.com/onmetal/onmetal-api/utils/envtest" "github.com/onmetal/onmetal-api/utils/envtest/apiserver" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" @@ -57,7 +58,7 @@ const ( pollingInterval = 50 * time.Millisecond eventuallyTimeout = 3 * time.Second consistentlyDuration = 1 * time.Second - apiServiceTimeout = 5 * time.Minute + apiServiceTimeout = 1 * time.Minute ) func TestControllers(t *testing.T) { @@ -76,16 +77,19 @@ var _ = BeforeSuite(func() { var err error By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "onmetal-api-net", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - } + testEnv = &envtest.Environment{} testEnvExt = &envtestutils.EnvironmentExtensions{ APIServiceDirectoryPaths: []string{ - modutils.Dir("github.com/onmetal/onmetal-api", "config", "apiserver", "apiservice", "bases"), + filepath.Join("..", "..", "config", "apiserver", "apiservice", "bases"), }, ErrorIfAPIServicePathIsMissing: true, } + onmetalAPIOpts := testEnvExt.AddAPIServerInstallOptions(envtestutils.APIServerInstallOptions{ + Paths: []string{ + modutils.Dir("github.com/onmetal/onmetal-api", "config", "apiserver", "apiservice", "bases"), + }, + ErrorIfPathMissing: true, + }) cfg, err = envtestutils.StartWithExtensions(testEnv, testEnvExt) Expect(err).NotTo(HaveOccurred()) @@ -94,88 +98,99 @@ var _ = BeforeSuite(func() { DeferCleanup(envtestutils.StopWithExtensions, testEnv, testEnvExt) Expect(networkingv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) - Expect(onmetalapinetv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) + Expect(ipamv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) + Expect(apinetv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) // Init package-level k8sClient k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) + SetClient(k8sClient) apiSrv, err := apiserver.New(cfg, apiserver.Options{ - MainPath: "github.com/onmetal/onmetal-api/cmd/onmetal-apiserver", + MainPath: "github.com/onmetal/onmetal-api-net/cmd/apiserver", BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, Host: testEnvExt.APIServiceInstallOptions.LocalServingHost, Port: testEnvExt.APIServiceInstallOptions.LocalServingPort, CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir, + Args: apiserver.ProcessArgs{ + "public-prefix": []string{"10.0.0.0/24"}, + }, }) Expect(err).NotTo(HaveOccurred()) Expect(apiSrv.Start()).To(Succeed()) DeferCleanup(apiSrv.Stop) + onmetalAPISrv, err := apiserver.New(cfg, apiserver.Options{ + MainPath: "github.com/onmetal/onmetal-api/cmd/onmetal-apiserver", + BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, + ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, + Host: onmetalAPIOpts.LocalServingHost, + Port: onmetalAPIOpts.LocalServingPort, + CertDir: onmetalAPIOpts.LocalServingCertDir, + }) + Expect(err).NotTo(HaveOccurred()) + + Expect(onmetalAPISrv.Start()).To(Succeed()) + DeferCleanup(onmetalAPISrv.Stop) + Expect(envtestutils.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed()) }) -func SetupTest(ctx context.Context) *corev1.Namespace { - var ( - cancel context.CancelFunc - ) - ns := &corev1.Namespace{} - - BeforeEach(func() { - var mgrCtx context.Context - mgrCtx, cancel = context.WithCancel(ctx) - *ns = corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "testns-", - }, - } - Expect(k8sClient.Create(ctx, ns)).To(Succeed(), "failed to create test namespace") - +func SetupTest(apiNetNamespace *corev1.Namespace) *corev1.Namespace { + BeforeEach(func(ctx SpecContext) { k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme.Scheme, - Host: "127.0.0.1", MetricsBindAddress: "0", }) Expect(err).ToNot(HaveOccurred()) + apiNetInterface := onmetalapinet.NewForConfigOrDie(cfg) + // register reconciler here Expect((&VirtualIPReconciler{ Client: k8sManager.GetClient(), APINetClient: k8sManager.GetClient(), - APINetNamespace: ns.Name, - }).SetupWithManager(k8sManager, k8sManager)).To(Succeed()) + APINetInterface: apiNetInterface, + APINetNamespace: apiNetNamespace.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) Expect((&NetworkReconciler{ Client: k8sManager.GetClient(), APINetClient: k8sManager.GetClient(), - APINetNamespace: ns.Name, - }).SetupWithManager(k8sManager, k8sManager)).To(Succeed()) + APINetNamespace: apiNetNamespace.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + + Expect((&NetworkInterfaceReconciler{ + Client: k8sManager.GetClient(), + APINetClient: k8sManager.GetClient(), + APINetNamespace: apiNetNamespace.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) Expect((&NATGatewayReconciler{ Client: k8sManager.GetClient(), APINetClient: k8sManager.GetClient(), - APINetNamespace: ns.Name, - }).SetupWithManager(k8sManager, k8sManager)).To(Succeed()) + APINetInterface: apiNetInterface, + APINetNamespace: apiNetNamespace.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) Expect((&LoadBalancerReconciler{ Client: k8sManager.GetClient(), APINetClient: k8sManager.GetClient(), - APINetNamespace: ns.Name, - }).SetupWithManager(k8sManager, k8sManager)).To(Succeed()) + APINetInterface: apiNetInterface, + APINetNamespace: apiNetNamespace.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + mgrCtx, cancel := context.WithCancel(context.Background()) + DeferCleanup(cancel) go func() { defer GinkgoRecover() Expect(k8sManager.Start(mgrCtx)).To(Succeed(), "failed to start manager") }() }) - AfterEach(func() { - cancel() - Expect(k8sClient.Delete(ctx, ns)).To(Succeed(), "failed to delete test namespace") - }) - - return ns + return apiNetNamespace } diff --git a/apinetlet/controllers/conversion.go b/apinetlet/controllers/conversion.go new file mode 100644 index 00000000..e710b3cb --- /dev/null +++ b/apinetlet/controllers/conversion.go @@ -0,0 +1,82 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "fmt" + + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + apinetv1alpha1ac "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + utilslices "github.com/onmetal/onmetal-api/utils/slices" +) + +func ipToAPINetIP(ip commonv1alpha1.IP) net.IP { + return net.IP{Addr: ip.Addr} +} + +func loadBalancerTypeToAPINetLoadBalancerType(loadBalancerType networkingv1alpha1.LoadBalancerType) (apinetv1alpha1.LoadBalancerType, error) { + switch loadBalancerType { + case networkingv1alpha1.LoadBalancerTypePublic: + return apinetv1alpha1.LoadBalancerTypePublic, nil + case networkingv1alpha1.LoadBalancerTypeInternal: + return apinetv1alpha1.LoadBalancerTypeInternal, nil + default: + return "", fmt.Errorf("unknown load balancer type %q", loadBalancerType) + } +} + +func loadBalancerPortToAPINetLoadBalancerPortConfig(port networkingv1alpha1.LoadBalancerPort) *apinetv1alpha1ac.LoadBalancerPortApplyConfiguration { + res := apinetv1alpha1ac.LoadBalancerPort(). + WithPort(port.Port) + res.Protocol = port.Protocol + res.EndPort = port.EndPort + return res +} + +func loadBalancerPortsToAPINetLoadBalancerPortConfigs(ports []networkingv1alpha1.LoadBalancerPort) []*apinetv1alpha1ac.LoadBalancerPortApplyConfiguration { + return utilslices.Map(ports, loadBalancerPortToAPINetLoadBalancerPortConfig) +} + +func apiNetIPToIP(ip net.IP) commonv1alpha1.IP { + return commonv1alpha1.IP{Addr: ip.Addr} +} + +func apiNetIPsToIPs(ips []net.IP) []commonv1alpha1.IP { + return utilslices.Map(ips, apiNetIPToIP) +} + +func apiNetIPPrefixToIPPrefix(prefix net.IPPrefix) commonv1alpha1.IPPrefix { + return commonv1alpha1.IPPrefix{Prefix: prefix.Prefix} +} + +func apiNetIPPrefixesToIPPrefixes(ips []net.IPPrefix) []commonv1alpha1.IPPrefix { + return utilslices.Map(ips, apiNetIPPrefixToIPPrefix) +} + +func apiNetNetworkInterfaceStateToNetworkInterfaceState(state apinetv1alpha1.NetworkInterfaceState) networkingv1alpha1.NetworkInterfaceState { + switch state { + case apinetv1alpha1.NetworkInterfaceStatePending: + return networkingv1alpha1.NetworkInterfaceStatePending + case apinetv1alpha1.NetworkInterfaceStateReady: + return networkingv1alpha1.NetworkInterfaceStateAvailable + case apinetv1alpha1.NetworkInterfaceStateError: + return networkingv1alpha1.NetworkInterfaceStateError + default: + return networkingv1alpha1.NetworkInterfaceStatePending + } +} diff --git a/apinetlet/controllers/helper.go b/apinetlet/controllers/helper.go index 4b8572db..1949c25c 100644 --- a/apinetlet/controllers/helper.go +++ b/apinetlet/controllers/helper.go @@ -15,16 +15,52 @@ package controllers import ( - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - "sigs.k8s.io/controller-runtime/pkg/event" + "context" + "fmt" + + ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/predicate" ) -func getApiNetPublicIPAllocationChangedPredicate() predicate.Funcs { - return predicate.Funcs{ - UpdateFunc: func(event event.UpdateEvent) bool { - oldAPINetPublicIP, newAPINetPublicIP := event.ObjectOld.(*onmetalapinetv1alpha1.PublicIP), event.ObjectNew.(*onmetalapinetv1alpha1.PublicIP) - return oldAPINetPublicIP.IsAllocated() != newAPINetPublicIP.IsAllocated() - }, +const fieldOwner = client.FieldOwner("api.onmetal.de/apinetlet") + +func getAPINetNetworkName(ctx context.Context, c client.Client, networkKey client.ObjectKey) (string, error) { + network := &networkingv1alpha1.Network{} + if err := c.Get(ctx, networkKey, network); err != nil { + if !apierrors.IsNotFound(err) { + return "", fmt.Errorf("error getting network %s for nat gateway: %w", networkKey.Name, err) + } + return "", nil } + return string(network.UID), nil +} + +func isPrefixAllocated(prefix *ipamv1alpha1.Prefix) bool { + return prefix.Status.Phase == ipamv1alpha1.PrefixPhaseAllocated +} + +type asNonDeletingObject struct { + client.Object +} + +func (o asNonDeletingObject) GetDeletionTimestamp() *metav1.Time { + return nil +} + +func virtualIPClaimedPredicate() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + vip := obj.(*networkingv1alpha1.VirtualIP) + return vip.Spec.TargetRef != nil + }) +} + +func virtualIPFreePredicate() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + vip := obj.(*networkingv1alpha1.VirtualIP) + return vip.Spec.TargetRef == nil + }) } diff --git a/apinetlet/controllers/helper_test.go b/apinetlet/controllers/helper_test.go new file mode 100644 index 00000000..67078169 --- /dev/null +++ b/apinetlet/controllers/helper_test.go @@ -0,0 +1,54 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +func SetupNetwork(ns, apiNetNS *corev1.Namespace) (*networkingv1alpha1.Network, *v1alpha1.Network) { + var ( + network = &networkingv1alpha1.Network{} + apiNetNetwork = &v1alpha1.Network{} + ) + + ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) { + ginkgo.By("creating a network") + *network = networkingv1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "network-", + }, + } + Expect(k8sClient.Create(ctx, network)) + + ginkgo.By("waiting for the APINet network to be present") + *apiNetNetwork = v1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: apiNetNS.Name, + Name: string(network.UID), + }, + } + Eventually(komega.Get(apiNetNetwork)).Should(Succeed()) + }) + + return network, apiNetNetwork +} diff --git a/apinetlet/controllers/loadbalancer_controller.go b/apinetlet/controllers/loadbalancer_controller.go index f526a22d..046bf2de 100644 --- a/apinetlet/controllers/loadbalancer_controller.go +++ b/apinetlet/controllers/loadbalancer_controller.go @@ -17,26 +17,31 @@ package controllers import ( "context" "fmt" - "net/netip" "strings" "github.com/go-logr/logr" "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + apinetlethandler "github.com/onmetal/onmetal-api-net/apinetlet/handler" + "github.com/onmetal/onmetal-api-net/apinetlet/provider" + apinetv1alpha1ac "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" "github.com/onmetal/onmetal-api/utils/predicates" + "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" ) @@ -46,7 +51,8 @@ const ( type LoadBalancerReconciler struct { client.Client - APINetClient client.Client + APINetClient client.Client + APINetInterface onmetalapinet.Interface APINetNamespace string @@ -57,8 +63,10 @@ type LoadBalancerReconciler struct { //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=loadbalancers,verbs=get;list;watch;update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=loadbalancers/finalizers,verbs=update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=loadbalancers/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips/status,verbs=get +//+kubebuilder:rbac:groups=ipam.api.onmetal.de,resources=prefix,verbs=get;list;watch + +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancers,verbs=get;list;watch;create;update;patch;delete;deletecollection +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancerroutings,verbs=get;list;watch;create;update;patch;delete;deletecollection func (r *LoadBalancerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) @@ -74,26 +82,22 @@ func (r *LoadBalancerReconciler) Reconcile(ctx context.Context, req ctrl.Request return r.reconcileExists(ctx, log, loadBalancer) } -func (r *LoadBalancerReconciler) deleteGone(ctx context.Context, log logr.Logger, virtualIPKey client.ObjectKey) (ctrl.Result, error) { +func (r *LoadBalancerReconciler) deleteGone(ctx context.Context, log logr.Logger, loadBalancerKey client.ObjectKey) (ctrl.Result, error) { log.V(1).Info("Delete gone") log.V(1).Info("Deleting any matching apinet public ips") - if err := r.APINetClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.PublicIP{}, + if err := r.APINetClient.DeleteAllOf(ctx, &apinetv1alpha1.LoadBalancer{}, client.InNamespace(r.APINetNamespace), - client.MatchingLabels{ - apinetletv1alpha1.LoadBalancerNamespaceLabel: virtualIPKey.Namespace, - apinetletv1alpha1.LoadBalancerNameLabel: virtualIPKey.Name, - }, + apinetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), loadBalancerKey, &networkingv1alpha1.LoadBalancer{}), ); err != nil { return ctrl.Result{}, fmt.Errorf("error deleting apinet public ips: %w", err) } - log.V(1).Info("Issued delete for any leftover apinet public ip") + log.V(1).Info("Issued delete for any leftover APINet public ip") return ctrl.Result{}, nil } func (r *LoadBalancerReconciler) reconcileExists(ctx context.Context, log logr.Logger, loadBalancer *networkingv1alpha1.LoadBalancer) (ctrl.Result, error) { - log = log.WithValues("UID", loadBalancer.UID) if !loadBalancer.DeletionTimestamp.IsZero() { return r.delete(ctx, log, loadBalancer) } @@ -108,33 +112,27 @@ func (r *LoadBalancerReconciler) delete(ctx context.Context, log logr.Logger, lo return ctrl.Result{}, nil } - var count int - for _, ipFamily := range loadBalancer.Spec.IPFamilies { - if err := r.APINetClient.Delete(ctx, &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: r.APINetNamespace, - Name: fmt.Sprintf("%s-%s", loadBalancer.UID, strings.ToLower(string(ipFamily))), - }, - }); err != nil { - if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error deleting target public ip: %w", err) - } - count++ - - } + apiNetLoadBalancer := &apinetv1alpha1.LoadBalancer{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.APINetNamespace, + Name: string(loadBalancer.UID), + }, } + if err := r.APINetClient.Delete(ctx, apiNetLoadBalancer); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error deleting apinet load balancer: %w", err) + } - if count < len(loadBalancer.Spec.IPFamilies) { - log.V(1).Info("Target public ip is not yet gone, requeueing") - return ctrl.Result{Requeue: true}, nil + log.V(1).Info("APINet load balancer is gone, removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, loadBalancer, loadBalancerFinalizer); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + log.V(1).Info("Deleted") + return ctrl.Result{}, nil } - log.V(1).Info("Target public ip is gone, removing finalizer") - if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, loadBalancer, loadBalancerFinalizer); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) - } - log.V(1).Info("Removed finalizer") - return ctrl.Result{}, nil + log.V(1).Info("Issued APINet load balancer deletion") + return ctrl.Result{Requeue: true}, nil } func (r *LoadBalancerReconciler) reconcile(ctx context.Context, log logr.Logger, loadBalancer *networkingv1alpha1.LoadBalancer) (ctrl.Result, error) { @@ -150,93 +148,192 @@ func (r *LoadBalancerReconciler) reconcile(ctx context.Context, log logr.Logger, return ctrl.Result{Requeue: true}, nil } - ips, err := r.applyPublicIPs(ctx, log, loadBalancer) + networkKey := client.ObjectKey{Namespace: loadBalancer.Namespace, Name: loadBalancer.Spec.NetworkRef.Name} + apiNetNetworkName, err := getAPINetNetworkName(ctx, r.Client, networkKey) if err != nil { - return ctrl.Result{}, fmt.Errorf("error getting / applying public ip: %w", err) + return ctrl.Result{}, err + } + if apiNetNetworkName == "" { + log.V(1).Info("APINet network is not ready") + return ctrl.Result{}, nil } - if err := r.patchStatus(ctx, log, loadBalancer, ips); err != nil { - return ctrl.Result{}, fmt.Errorf("error patching load balancer status") + log.V(1).Info("Applying APINet load balancer") + apiNetLoadBalancer, err := r.applyAPINetLoadBalancer(ctx, loadBalancer, apiNetNetworkName) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error applying apinet load balancer: %w", err) + } + + log.V(1).Info("Manage APINet load balancer routing") + if err := r.manageAPINetLoadBalancerRouting(ctx, loadBalancer, apiNetLoadBalancer); err != nil { + return ctrl.Result{}, err + } + + actualIPs := apiNetIPsToIPs(apiNetLoadBalancer.Status.IPs) + if !slices.Equal(actualIPs, loadBalancer.Status.IPs) { + log.V(1).Info("Updating load balancer status IPs") + if err := r.updateLoadBalancerIPs(ctx, loadBalancer, actualIPs); err != nil { + return ctrl.Result{}, fmt.Errorf("error patching load balancer status") + } } log.V(1).Info("Patched load balancer status") return ctrl.Result{}, nil } -func (r *LoadBalancerReconciler) applyPublicIPs(ctx context.Context, log logr.Logger, loadBalancer *networkingv1alpha1.LoadBalancer) ([]netip.Addr, error) { - var ips []netip.Addr - for _, ipFamily := range loadBalancer.Spec.IPFamilies { - apiNetPublicIP, err := r.applyPublicIP(ctx, log, loadBalancer, ipFamily) - if err != nil { - return nil, err +func (r *LoadBalancerReconciler) manageAPINetLoadBalancerRouting( + ctx context.Context, + loadBalancer *networkingv1alpha1.LoadBalancer, + apiNetLoadBalancer *apinetv1alpha1.LoadBalancer, +) error { + loadBalancerRouting := &networkingv1alpha1.LoadBalancerRouting{} + if err := r.Get(ctx, client.ObjectKeyFromObject(loadBalancer), loadBalancerRouting); client.IgnoreNotFound(err) != nil { + return fmt.Errorf("error getting load balancer routing: %w", err) + } + + apiNetDsts := make([]apinetv1alpha1.LoadBalancerDestination, 0) + for _, dst := range loadBalancerRouting.Destinations { + var apiNetTargetRef *apinetv1alpha1.LoadBalancerTargetRef + if targetRef := dst.TargetRef; targetRef != nil { + _, name, node, uid, err := provider.ParseNetworkInterfaceID(targetRef.ProviderID) + if err == nil { + apiNetTargetRef = &apinetv1alpha1.LoadBalancerTargetRef{ + UID: uid, + Name: name, + NodeRef: corev1.LocalObjectReference{ + Name: node, + }, + } + } } - ips = append(ips, apiNetPublicIP) + apiNetDsts = append(apiNetDsts, apinetv1alpha1.LoadBalancerDestination{ + IP: ipToAPINetIP(dst.IP), + TargetRef: apiNetTargetRef, + }) } - return ips, nil -} -func (r *LoadBalancerReconciler) applyPublicIP(ctx context.Context, log logr.Logger, loadBalancer *networkingv1alpha1.LoadBalancer, ipFamily corev1.IPFamily) (netip.Addr, error) { - apiNetPublicIP := &onmetalapinetv1alpha1.PublicIP{ + apiNetLoadBalancerRouting := &apinetv1alpha1.LoadBalancerRouting{ TypeMeta: metav1.TypeMeta{ - APIVersion: onmetalapinetv1alpha1.GroupVersion.String(), - Kind: "PublicIP", + APIVersion: apinetv1alpha1.SchemeGroupVersion.String(), + Kind: "LoadBalancerRouting", }, ObjectMeta: metav1.ObjectMeta{ Namespace: r.APINetNamespace, - Name: fmt.Sprintf("%s-%s", loadBalancer.UID, strings.ToLower(string(ipFamily))), - Labels: map[string]string{ - apinetletv1alpha1.LoadBalancerNamespaceLabel: loadBalancer.Namespace, - apinetletv1alpha1.LoadBalancerNameLabel: loadBalancer.Name, - apinetletv1alpha1.LoadBalancerUIDLabel: string(loadBalancer.UID), + Name: apiNetLoadBalancer.Name, + Labels: apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), loadBalancer), + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(apiNetLoadBalancer, apinetv1alpha1.SchemeGroupVersion.WithKind("LoadBalancer")), }, }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: ipFamily, - }, + Destinations: apiNetDsts, + } + if err := r.APINetClient.Patch(ctx, apiNetLoadBalancerRouting, client.Apply, fieldOwner, client.ForceOwnership); err != nil { + return fmt.Errorf("error applying apinet load balancer routing: %w", err) } + return nil +} - log.V(1).Info("Applying apinet public ip", "ipFamily", ipFamily) - if err := r.APINetClient.Patch(ctx, apiNetPublicIP, client.Apply, - client.FieldOwner(apinetletv1alpha1.FieldOwner), - client.ForceOwnership, - ); err != nil { - return netip.Addr{}, fmt.Errorf("error applying apinet public ip: %w", err) +func (r *LoadBalancerReconciler) getPublicLoadBalancerAPINetIPs( + loadBalancer *networkingv1alpha1.LoadBalancer, +) []*apinetv1alpha1ac.LoadBalancerIPApplyConfiguration { + res := make([]*apinetv1alpha1ac.LoadBalancerIPApplyConfiguration, len(loadBalancer.Spec.IPFamilies)) + for i, ipFamily := range loadBalancer.Spec.IPFamilies { + res[i] = apinetv1alpha1ac.LoadBalancerIP(). + WithName(strings.ToLower(string(ipFamily))). + WithIPFamily(ipFamily) } - log.V(1).Info("Applied apinet public ip") + return res +} + +func (r *LoadBalancerReconciler) getInternalLoadBalancerAPINetIPs( + ctx context.Context, + loadBalancer *networkingv1alpha1.LoadBalancer, +) ([]*apinetv1alpha1ac.LoadBalancerIPApplyConfiguration, error) { + var ips []*apinetv1alpha1ac.LoadBalancerIPApplyConfiguration + for i, ip := range loadBalancer.Spec.IPs { + switch { + case ip.Value != nil: + ips = append(ips, + apinetv1alpha1ac.LoadBalancerIP(). + WithName(fmt.Sprintf("ip-%d", i)). + WithIPFamily(ip.Value.Family()). + WithIP(net.IP{Addr: ip.Value.Addr}), + ) + case ip.Ephemeral != nil: + prefix := &ipamv1alpha1.Prefix{} + prefixName := networkingv1alpha1.LoadBalancerIPIPAMPrefixName(loadBalancer.Name, i) + prefixKey := client.ObjectKey{Namespace: loadBalancer.Namespace, Name: prefixName} + if err := r.Get(ctx, prefixKey, prefix); err != nil { + if !apierrors.IsNotFound(err) { + return nil, fmt.Errorf("error getting prefix %s: %w", prefixName, err) + } + + continue + } + + if !metav1.IsControlledBy(prefix, loadBalancer) { + // Don't use a prefix that is not controlled by the load balancer. + continue + } - if !apiNetPublicIP.IsAllocated() { - return netip.Addr{}, nil + if !isPrefixAllocated(prefix) { + continue + } + + ips = append(ips, + apinetv1alpha1ac.LoadBalancerIP(). + WithName(fmt.Sprintf("ip-%d", i)). + WithIPFamily(prefix.Spec.IPFamily). + WithIP(net.IP{Addr: prefix.Spec.Prefix.IP().Addr}), + ) + } } - ip := apiNetPublicIP.Spec.IP - return ip.Addr, nil + return ips, nil } -func (r *LoadBalancerReconciler) patchStatus(ctx context.Context, log logr.Logger, loadBalancer *networkingv1alpha1.LoadBalancer, ips []netip.Addr) error { - base := loadBalancer.DeepCopy() - loadBalancer.Status.IPs = []commonv1alpha1.IP{} +func (r *LoadBalancerReconciler) applyAPINetLoadBalancer(ctx context.Context, loadBalancer *networkingv1alpha1.LoadBalancer, apiNetNetworkName string) (*apinetv1alpha1.LoadBalancer, error) { + apiNetLoadBalancerType, err := loadBalancerTypeToAPINetLoadBalancerType(loadBalancer.Spec.Type) + if err != nil { + return nil, err + } - for _, ip := range ips { - if !ip.IsValid() { - log.V(2).Info("Public ip is not yet allocated", "ip", ip.String()) - continue + var ips []*apinetv1alpha1ac.LoadBalancerIPApplyConfiguration + switch loadBalancer.Spec.Type { + case networkingv1alpha1.LoadBalancerTypeInternal: + ips, err = r.getInternalLoadBalancerAPINetIPs(ctx, loadBalancer) + if err != nil { + return nil, err } + case networkingv1alpha1.LoadBalancerTypePublic: + ips = r.getPublicLoadBalancerAPINetIPs(loadBalancer) + } - log.V(2).Info("Public ip is allocated", "ip", ip.String()) - loadBalancer.Status.IPs = append(loadBalancer.Status.IPs, commonv1alpha1.IP{ - Addr: ip, - }) + apiNetLoadBalancerApplyCfg := + apinetv1alpha1ac.LoadBalancer(string(loadBalancer.UID), r.APINetNamespace). + WithLabels(apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), loadBalancer)). + WithSpec(apinetv1alpha1ac.LoadBalancerSpec(). + WithType(apiNetLoadBalancerType). + WithNetworkRef(corev1.LocalObjectReference{Name: apiNetNetworkName}). + WithIPs(ips...). + WithPorts(loadBalancerPortsToAPINetLoadBalancerPortConfigs(loadBalancer.Spec.Ports)...), + ) + apiNetLoadBalancer, err := r.APINetInterface.CoreV1alpha1(). + LoadBalancers(r.APINetNamespace). + Apply(ctx, apiNetLoadBalancerApplyCfg, metav1.ApplyOptions{FieldManager: string(fieldOwner), Force: true}) + if err != nil { + return nil, fmt.Errorf("error applying apinet load balancer: %w", err) } + return apiNetLoadBalancer, nil +} +func (r *LoadBalancerReconciler) updateLoadBalancerIPs(ctx context.Context, loadBalancer *networkingv1alpha1.LoadBalancer, ips []commonv1alpha1.IP) error { + base := loadBalancer.DeepCopy() + loadBalancer.Status.IPs = ips return r.Status().Patch(ctx, loadBalancer, client.MergeFrom(base)) } -var isLoadBalancerTypePublic = predicate.NewPredicateFuncs(func(obj client.Object) bool { - loadBalancer := obj.(*networkingv1alpha1.LoadBalancer) - return loadBalancer.Spec.Type == networkingv1alpha1.LoadBalancerTypePublic -}) - -func (r *LoadBalancerReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster cluster.Cluster) error { +func (r *LoadBalancerReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCache cache.Cache) error { log := ctrl.Log.WithName("loadbalancer").WithName("setup") return ctrl.NewControllerManagedBy(mgr). @@ -245,33 +342,16 @@ func (r *LoadBalancerReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluste builder.WithPredicates( predicates.ResourceHasFilterLabel(log, r.WatchFilterValue), predicates.ResourceIsNotExternallyManaged(log), - isLoadBalancerTypePublic, ), ). WatchesRawSource( - source.Kind(apiNetCluster.GetCache(), &onmetalapinetv1alpha1.PublicIP{}), - handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { - apiNetPublicIP := obj.(*onmetalapinetv1alpha1.PublicIP) - - if apiNetPublicIP.Namespace != r.APINetNamespace { - return nil - } - - namespace, ok := apiNetPublicIP.Labels[apinetletv1alpha1.LoadBalancerNamespaceLabel] - if !ok { - return nil - } - - name, ok := apiNetPublicIP.Labels[apinetletv1alpha1.LoadBalancerNameLabel] - if !ok { - return nil - } - - return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: namespace, Name: name}}} - }), - builder.WithPredicates( - getApiNetPublicIPAllocationChangedPredicate(), - ), + source.Kind(apiNetCache, &apinetv1alpha1.LoadBalancer{}), + apinetlethandler.EnqueueRequestForSource(r.Scheme(), r.RESTMapper(), &networkingv1alpha1.LoadBalancer{}), + ). + Owns(&ipamv1alpha1.Prefix{}). + Watches( + &networkingv1alpha1.LoadBalancerRouting{}, + &handler.EnqueueRequestForObject{}, ). Complete(r) } diff --git a/apinetlet/controllers/loadbalancer_controller_test.go b/apinetlet/controllers/loadbalancer_controller_test.go index b59a7985..1786f9fb 100644 --- a/apinetlet/controllers/loadbalancer_controller_test.go +++ b/apinetlet/controllers/loadbalancer_controller_test.go @@ -15,39 +15,26 @@ package controllers import ( - "fmt" - "strings" - - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" ) var _ = Describe("LoadBalancerController", func() { - ctx := SetupContext() - ns := SetupTest(ctx) + ns := SetupNamespace(&k8sClient) + apiNetNs := SetupNamespace(&k8sClient) + SetupTest(apiNetNs) - It("should allocate a public ip", func() { - By("creating a network") - network := &networkingv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", - }, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - ipFamily := corev1.IPv4Protocol + network, apiNetNetwork := SetupNetwork(ns, apiNetNs) + It("should manage the APINet load balancer and its IPs", func(ctx SpecContext) { By("creating a load balancer") loadBalancer := &networkingv1alpha1.LoadBalancer{ ObjectMeta: metav1.ObjectMeta{ @@ -55,153 +42,30 @@ var _ = Describe("LoadBalancerController", func() { GenerateName: "load-balancer-", }, Spec: networkingv1alpha1.LoadBalancerSpec{ - Type: networkingv1alpha1.LoadBalancerTypePublic, - IPFamilies: []corev1.IPFamily{ - ipFamily, - }, + Type: networkingv1alpha1.LoadBalancerTypePublic, + IPFamilies: []corev1.IPFamily{corev1.IPv4Protocol}, NetworkRef: corev1.LocalObjectReference{Name: network.Name}, }, } Expect(k8sClient.Create(ctx, loadBalancer)).To(Succeed()) - By("waiting for the corresponding public ip to be created") - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: fmt.Sprintf("%s-%s", loadBalancer.UID, strings.ToLower(string(ipFamily))), - }, - } - Eventually(Get(publicIP)).Should(Succeed()) - - By("inspecting the created public ip") - Expect(publicIP.Labels).To(Equal(map[string]string{ - apinetletv1alpha1.LoadBalancerNamespaceLabel: loadBalancer.Namespace, - apinetletv1alpha1.LoadBalancerNameLabel: loadBalancer.Name, - apinetletv1alpha1.LoadBalancerUIDLabel: string(loadBalancer.UID), - })) - Expect(publicIP.Spec).To(Equal(onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: ipFamily, - })) - - By("asserting the load balancer does not get an ip address") - Consistently(Object(loadBalancer)).Should(HaveField("Status.IPs", BeNil())) - - By("patching the public ip spec ips") - basePublicIP := publicIP.DeepCopy() - publicIP.Spec.IP = onmetalapinetv1alpha1.MustParseNewIP("10.0.0.1") - Expect(k8sClient.Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) - - By("patching the public ip status to allocated") - basePublicIP = publicIP.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) - - By("checking that load balancer contains ip") - Eventually(Object(loadBalancer)).Should(HaveField("Status.IPs", - ContainElement(*commonv1alpha1.MustParseNewIP("10.0.0.1")), - )) - - ipFamily2 := corev1.IPv6Protocol - - By("requesting further ip by adding another protocol") - loadBalancerBase := loadBalancer.DeepCopy() - loadBalancer.Spec.IPFamilies = append(loadBalancer.Spec.IPFamilies, ipFamily2) - Expect(k8sClient.Patch(ctx, loadBalancer, client.MergeFrom(loadBalancerBase))).To(Succeed()) - - By("waiting for the corresponding public ip to be created") - publicIP2 := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: fmt.Sprintf("%s-%s", loadBalancer.UID, strings.ToLower(string(ipFamily2))), - }, - } - Eventually(Get(publicIP2)).Should(Succeed()) - - By("patching the second public ip spec ips") - basePublicIP2 := publicIP2.DeepCopy() - publicIP2.Spec.IP = onmetalapinetv1alpha1.MustParseNewIP("::ffff:a00:2") - Expect(k8sClient.Patch(ctx, publicIP2, client.MergeFrom(basePublicIP2))).To(Succeed()) - - By("patching the second public ip status to allocated") - basePublicIP2 = publicIP2.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP2.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, publicIP2, client.MergeFrom(basePublicIP2))).To(Succeed()) - - By("checking that load balancer contains ips") - Eventually(Object(loadBalancer)).Should(HaveField("Status.IPs", - ContainElements( - *commonv1alpha1.MustParseNewIP("10.0.0.1"), - *commonv1alpha1.MustParseNewIP("::ffff:a00:2"), - ), - )) - - By("deleting the load balancer") - Expect(k8sClient.Delete(ctx, loadBalancer)).To(Succeed()) - - By("waiting for it to be gone") - Eventually(Get(loadBalancer)).Should(Satisfy(apierrors.IsNotFound)) - - By("asserting the corresponding public ips are gone as well") - Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(publicIP), publicIP)).To(Satisfy(apierrors.IsNotFound)) - Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(publicIP2), publicIP2)).To(Satisfy(apierrors.IsNotFound)) - }) - - It("should clean up dangling public ips", func() { - By("creating a public ip") - publicIP := &onmetalapinetv1alpha1.PublicIP{ + By("waiting for the APINet load balancer to exist") + apiNetLoadBalancer := &v1alpha1.LoadBalancer{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "public-ip-", - Labels: map[string]string{ - apinetletv1alpha1.LoadBalancerNamespaceLabel: ns.Name, - apinetletv1alpha1.LoadBalancerNameLabel: "some-name", - apinetletv1alpha1.LoadBalancerUIDLabel: "some-uid", - }, - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - - By("waiting for the public ip to be gone") - Eventually(Get(publicIP)).Should(Satisfy(apierrors.IsNotFound)) - }) - - It("should not allocate public IPs for internal load balancers", func() { - By("creating a network") - network := &networkingv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", + Namespace: apiNetNs.Name, + Name: string(loadBalancer.UID), }, } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - By("creating an internal load balancer") - loadBalancer := &networkingv1alpha1.LoadBalancer{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "internal-lb-", - }, - Spec: networkingv1alpha1.LoadBalancerSpec{ - Type: networkingv1alpha1.LoadBalancerTypeInternal, - NetworkRef: corev1.LocalObjectReference{Name: network.Name}, - IPFamilies: []corev1.IPFamily{corev1.IPv4Protocol}, - IPs: []networkingv1alpha1.IPSource{ - {Value: commonv1alpha1.MustParseNewIP("10.0.0.1")}, - }, - }, - } - Expect(k8sClient.Create(ctx, loadBalancer)).To(Succeed()) - - By("asserting it does not get a public IP") - Consistently(Object(loadBalancer)).Should(HaveField("Status.IPs", BeEmpty())) + Eventually(Object(apiNetLoadBalancer)).Should(SatisfyAll( + HaveField("Labels", apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), loadBalancer)), + HaveField("Spec", MatchFields(IgnoreExtras, Fields{ + "Type": Equal(v1alpha1.LoadBalancerTypePublic), + "NetworkRef": Equal(corev1.LocalObjectReference{Name: apiNetNetwork.Name}), + "IPs": ConsistOf(MatchFields(IgnoreExtras, Fields{ + "IPFamily": Equal(corev1.IPv4Protocol), + "Name": Equal("ipv4"), + })), + }))), + ) }) }) diff --git a/apinetlet/controllers/natgateway_controller.go b/apinetlet/controllers/natgateway_controller.go index 41c2b78e..1eca7fb1 100644 --- a/apinetlet/controllers/natgateway_controller.go +++ b/apinetlet/controllers/natgateway_controller.go @@ -1,4 +1,4 @@ -// Copyright 2022 OnMetal authors +// Copyright 2023 OnMetal authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,25 +17,28 @@ package controllers import ( "context" "fmt" - "net/netip" - "strings" + "slices" "github.com/go-logr/logr" "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + "github.com/onmetal/onmetal-api-net/apinetlet/handler" + apinetv1alpha1ac "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + "github.com/onmetal/onmetal-api/utils/generic" "github.com/onmetal/onmetal-api/utils/predicates" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/source" ) @@ -45,54 +48,48 @@ const ( type NATGatewayReconciler struct { client.Client - APINetClient client.Client - + APINetClient client.Client + APINetInterface onmetalapinet.Interface APINetNamespace string WatchFilterValue string } -//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=natgateways,verbs=get;list;watch;update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=natgateways/finalizers,verbs=update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=natgateways/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips/status,verbs=get + +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgateways,verbs=get;list;watch;create;update;patch;delete;deletecollection +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgatewayautoscalers,verbs=get;list;watch;create;update;patch;delete;deletecollection func (r *NATGatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) natGateway := &networkingv1alpha1.NATGateway{} if err := r.Get(ctx, req.NamespacedName, natGateway); err != nil { if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error getting nat gateway %s: %w", req.NamespacedName, err) + return ctrl.Result{}, fmt.Errorf("error getting nat gateway: %w", err) } - return r.deleteGone(ctx, log, req.NamespacedName) } - return r.reconcileExists(ctx, log, natGateway) } -func (r *NATGatewayReconciler) deleteGone(ctx context.Context, log logr.Logger, natGatewayKey client.ObjectKey) (ctrl.Result, error) { +func (r *NATGatewayReconciler) deleteGone(ctx context.Context, log logr.Logger, key client.ObjectKey) (ctrl.Result, error) { log.V(1).Info("Delete gone") - log.V(1).Info("Deleting any matching apinet public ips") - if err := r.APINetClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.PublicIP{}, + log.V(1).Info("Deleting any APINet NAT gateway by key") + if err := r.APINetClient.DeleteAllOf(ctx, &v1alpha1.NATGateway{}, client.InNamespace(r.APINetNamespace), - client.MatchingLabels{ - apinetletv1alpha1.NATGatewayNamespaceLabel: natGatewayKey.Namespace, - apinetletv1alpha1.NATGatewayNameLabel: natGatewayKey.Name, - }, + apinetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), key, &networkingv1alpha1.NATGateway{}), ); err != nil { - return ctrl.Result{}, fmt.Errorf("error deleting apinet public ips: %w", err) + return ctrl.Result{}, fmt.Errorf("error deleting apinet nat gateways by key: %w", err) } - log.V(1).Info("Issued delete for any leftover apinet public ip") + log.V(1).Info("Deleted gone") return ctrl.Result{}, nil } func (r *NATGatewayReconciler) reconcileExists(ctx context.Context, log logr.Logger, natGateway *networkingv1alpha1.NATGateway) (ctrl.Result, error) { - log = log.WithValues("UID", natGateway.UID) if !natGateway.DeletionTimestamp.IsZero() { return r.delete(ctx, log, natGateway) } @@ -106,37 +103,30 @@ func (r *NATGatewayReconciler) delete(ctx context.Context, log logr.Logger, natG log.V(1).Info("No finalizer present, nothing to do") return ctrl.Result{}, nil } + log.V(1).Info("Finalizer present, running cleanup") - var count int - for _, ipFamily := range natGateway.Spec.IPFamilies { - for _, ip := range natGateway.Spec.IPs { - if err := r.APINetClient.Delete(ctx, &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: r.APINetNamespace, - Name: fmt.Sprintf("%s-%s-%s", natGateway.UID, ip.Name, strings.ToLower(string(ipFamily))), - }, - }); err != nil { - if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error deleting target public ip: %w", err) - } - count++ - - } - - } + log.V(1).Info("Deleting APINet NAT gateway") + apiNetNATGateway := &v1alpha1.NATGateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.APINetNamespace, + Name: string(natGateway.UID), + }, } + if err := r.APINetClient.Delete(ctx, apiNetNATGateway); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error deleting apinet NAT Gateway: %w", err) + } - if count < len(natGateway.Spec.IPs)*len(natGateway.Spec.IPFamilies) { - log.V(1).Info("Target public ip is not yet gone, requeueing") - return ctrl.Result{Requeue: true}, nil + log.V(1).Info("APINet NAT gateway is gone, removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, natGateway, natGatewayFinalizer); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing NAT gateway finalizer: %w", err) + } + log.V(1).Info("Deleted") + return ctrl.Result{}, nil } - log.V(1).Info("Target public ip is gone, removing finalizer") - if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, natGateway, natGatewayFinalizer); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) - } - log.V(1).Info("Removed finalizer") - return ctrl.Result{}, nil + log.V(1).Info("Issued APINet NAT gateway deletion") + return ctrl.Result{Requeue: true}, nil } func (r *NATGatewayReconciler) reconcile(ctx context.Context, log logr.Logger, natGateway *networkingv1alpha1.NATGateway) (ctrl.Result, error) { @@ -151,93 +141,78 @@ func (r *NATGatewayReconciler) reconcile(ctx context.Context, log logr.Logger, n log.V(1).Info("Added finalizer, requeueing") return ctrl.Result{Requeue: true}, nil } + log.V(1).Info("Finalizer is present") - ips, err := r.applyPublicIPs(ctx, log, natGateway) + networkKey := client.ObjectKey{Namespace: natGateway.Namespace, Name: natGateway.Spec.NetworkRef.Name} + networkName, err := getAPINetNetworkName(ctx, r.Client, networkKey) if err != nil { - return ctrl.Result{}, fmt.Errorf("error getting / applying public ip: %w", err) + return ctrl.Result{}, fmt.Errorf("error getting apinet network name: %w", err) } - - if err := r.patchStatus(ctx, log, natGateway, ips); err != nil { - return ctrl.Result{}, fmt.Errorf("error patching nat gateway status") + if networkName == "" { + log.V(1).Info("APINet network is not ready") + return ctrl.Result{}, nil } - log.V(1).Info("Patched nat gateway status") - return ctrl.Result{}, nil -} + apiNetNATGatewayCfg := + apinetv1alpha1ac.NATGateway(string(natGateway.UID), r.APINetNamespace). + WithLabels(apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), natGateway)). + WithSpec(apinetv1alpha1ac.NATGatewaySpec(). + WithIPFamily(natGateway.Spec.IPFamily). + WithNetworkRef(corev1.LocalObjectReference{Name: networkName}). + WithPortsPerNetworkInterface(generic.Deref( + natGateway.Spec.PortsPerNetworkInterface, + networkingv1alpha1.DefaultPortsPerNetworkInterface, + )), + ) + apiNetNATGateway, err := r.APINetInterface.CoreV1alpha1(). + NATGateways(r.APINetNamespace). + Apply(ctx, apiNetNATGatewayCfg, metav1.ApplyOptions{FieldManager: string(fieldOwner), Force: true}) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error applying apinet nat gateway: %w", err) + } -func (r *NATGatewayReconciler) applyPublicIP(ctx context.Context, log logr.Logger, natGateway *networkingv1alpha1.NATGateway, ipName string, ipFamily corev1.IPFamily) (netip.Addr, error) { - apiNetPublicIP := &onmetalapinetv1alpha1.PublicIP{ + apiNetNATGatewayAutoscaler := &v1alpha1.NATGatewayAutoscaler{ TypeMeta: metav1.TypeMeta{ - APIVersion: onmetalapinetv1alpha1.GroupVersion.String(), - Kind: "PublicIP", + APIVersion: apinetv1alpha1.SchemeGroupVersion.String(), + Kind: "NATGatewayAutoscaler", }, ObjectMeta: metav1.ObjectMeta{ Namespace: r.APINetNamespace, - Name: fmt.Sprintf("%s-%s-%s", natGateway.UID, ipName, strings.ToLower(string(ipFamily))), - Labels: map[string]string{ - apinetletv1alpha1.NATGatewayNamespaceLabel: natGateway.Namespace, - apinetletv1alpha1.NATGatewayNameLabel: natGateway.Name, - apinetletv1alpha1.NATGatewayUIDLabel: string(natGateway.UID), - }, + Name: string(natGateway.UID), + Labels: apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), natGateway), }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: ipFamily, + Spec: v1alpha1.NATGatewayAutoscalerSpec{ + NATGatewayRef: corev1.LocalObjectReference{Name: apiNetNATGateway.Name}, }, } - - log.V(1).Info("Applying apinet public ip", "ipName", ipName, "ipFamily", ipFamily) - if err := r.APINetClient.Patch(ctx, apiNetPublicIP, client.Apply, - client.FieldOwner(apinetletv1alpha1.FieldOwner), - client.ForceOwnership, - ); err != nil { - return netip.Addr{}, fmt.Errorf("error applying apinet public ip: %w", err) + _ = ctrl.SetControllerReference(apiNetNATGateway, apiNetNATGatewayAutoscaler, r.Scheme()) + if err := r.APINetClient.Patch(ctx, apiNetNATGatewayAutoscaler, client.Apply, client.ForceOwnership, fieldOwner); err != nil { + return ctrl.Result{}, fmt.Errorf("error applying apinet NAT gateway autoscaler: %w", err) } - log.V(1).Info("Applied apinet public ip") - if !apiNetPublicIP.IsAllocated() { - return netip.Addr{}, nil - } - ip := apiNetPublicIP.Spec.IP - return ip.Addr, nil -} - -func (r *NATGatewayReconciler) applyPublicIPs(ctx context.Context, log logr.Logger, natGateway *networkingv1alpha1.NATGateway) (map[string]netip.Addr, error) { - ips := map[string]netip.Addr{} - for _, ipFamily := range natGateway.Spec.IPFamilies { - for _, ip := range natGateway.Spec.IPs { - apiNetPublicIP, err := r.applyPublicIP(ctx, log, natGateway, ip.Name, ipFamily) - if err != nil { - return nil, err - } - ips[ip.Name] = apiNetPublicIP + natGatewayIPs := apiNetIPsToIPs(v1alpha1.GetNATGatewayIPs(apiNetNATGateway)) + if !slices.Equal(natGateway.Status.IPs, natGatewayIPs) { + if err := r.updateNATGatewayStatus(ctx, natGateway, natGatewayIPs); err != nil { + return ctrl.Result{}, fmt.Errorf("error updating NAT gateway status IPs: %w", err) } + log.V(1).Info("Updated NAT gateway status IPs", "ips", natGatewayIPs) } - return ips, nil + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil } -func (r *NATGatewayReconciler) patchStatus(ctx context.Context, log logr.Logger, natGateway *networkingv1alpha1.NATGateway, ips map[string]netip.Addr) error { +func (r *NATGatewayReconciler) updateNATGatewayStatus( + ctx context.Context, + natGateway *networkingv1alpha1.NATGateway, + ips []commonv1alpha1.IP, +) error { base := natGateway.DeepCopy() - natGateway.Status.IPs = []networkingv1alpha1.NATGatewayIPStatus{} - - for ipName, ip := range ips { - if !ip.IsValid() { - log.V(2).Info("Public ip is not yet allocated", "ipName", ipName) - continue - } - - log.V(2).Info("Public ip is allocated", "ipName", ipName) - natGateway.Status.IPs = append(natGateway.Status.IPs, networkingv1alpha1.NATGatewayIPStatus{ - Name: ipName, - IP: commonv1alpha1.IP{ - Addr: ip, - }, - }) - } - - return r.Status().Patch(ctx, natGateway, client.MergeFrom(base)) + natGateway.Status.IPs = ips + return r.Status().Patch(ctx, natGateway, client.StrategicMergeFrom(base)) } -func (r *NATGatewayReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster cluster.Cluster) error { +func (r *NATGatewayReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCache cache.Cache) error { log := ctrl.Log.WithName("natgateway").WithName("setup") return ctrl.NewControllerManagedBy(mgr). @@ -249,29 +224,12 @@ func (r *NATGatewayReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster ), ). WatchesRawSource( - source.Kind(apiNetCluster.GetCache(), &onmetalapinetv1alpha1.PublicIP{}), - handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { - apiNetPublicIP := obj.(*onmetalapinetv1alpha1.PublicIP) - - if apiNetPublicIP.Namespace != r.APINetNamespace { - return nil - } - - namespace, ok := apiNetPublicIP.Labels[apinetletv1alpha1.NATGatewayNamespaceLabel] - if !ok { - return nil - } - - name, ok := apiNetPublicIP.Labels[apinetletv1alpha1.NATGatewayNameLabel] - if !ok { - return nil - } - - return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: namespace, Name: name}}} - }), - builder.WithPredicates( - getApiNetPublicIPAllocationChangedPredicate(), - ), + source.Kind(apiNetCache, &v1alpha1.NATGateway{}), + handler.EnqueueRequestForSource(mgr.GetScheme(), mgr.GetRESTMapper(), &networkingv1alpha1.NATGateway{}), + ). + WatchesRawSource( + source.Kind(apiNetCache, &v1alpha1.NATGatewayAutoscaler{}), + handler.EnqueueRequestForSource(mgr.GetScheme(), mgr.GetRESTMapper(), &networkingv1alpha1.NATGateway{}), ). Complete(r) } diff --git a/apinetlet/controllers/natgateway_controller_test.go b/apinetlet/controllers/natgateway_controller_test.go index 3af2b58b..64335c7c 100644 --- a/apinetlet/controllers/natgateway_controller_test.go +++ b/apinetlet/controllers/natgateway_controller_test.go @@ -15,40 +15,24 @@ package controllers import ( - "fmt" - "strings" - - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" - commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" ) var _ = Describe("NATGatewayController", func() { - ctx := SetupContext() - ns := SetupTest(ctx) - - It("should allocate a public ip", func() { - By("creating a network") - network := &networkingv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", - }, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - ipName := "ip" - ipFamily := corev1.IPv4Protocol + ns := SetupNamespace(&k8sClient) + apiNetNs := SetupNamespace(&k8sClient) + SetupTest(apiNetNs) + network, _ := SetupNetwork(ns, apiNetNs) + It("should allocate a public ip", func(ctx SpecContext) { By("creating a nat gateway") natGateway := &networkingv1alpha1.NATGateway{ ObjectMeta: metav1.ObjectMeta{ @@ -56,135 +40,36 @@ var _ = Describe("NATGatewayController", func() { GenerateName: "nat-gateway-", }, Spec: networkingv1alpha1.NATGatewaySpec{ - Type: networkingv1alpha1.NATGatewayTypePublic, - IPFamilies: []corev1.IPFamily{ - ipFamily, - }, + Type: networkingv1alpha1.NATGatewayTypePublic, + IPFamily: corev1.IPv4Protocol, NetworkRef: corev1.LocalObjectReference{Name: network.Name}, - IPs: []networkingv1alpha1.NATGatewayIP{ - { - Name: ipName, - }, - }, }, } Expect(k8sClient.Create(ctx, natGateway)).To(Succeed()) - By("waiting for the corresponding public ip to be created") - publicIP := &onmetalapinetv1alpha1.PublicIP{ + By("waiting for the APINet NAT gateway to be present") + apiNetNATGateway := &v1alpha1.NATGateway{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: fmt.Sprintf("%s-%s-%s", natGateway.UID, ipName, strings.ToLower(string(ipFamily))), + Namespace: apiNetNs.Name, + Name: string(natGateway.UID), }, } - Eventually(Get(publicIP)).Should(Succeed()) + Eventually(Object(apiNetNATGateway)).Should( + HaveField("Labels", apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), natGateway)), + ) - By("inspecting the created public ip") - Expect(publicIP.Labels).To(Equal(map[string]string{ - apinetletv1alpha1.NATGatewayNamespaceLabel: natGateway.Namespace, - apinetletv1alpha1.NATGatewayNameLabel: natGateway.Name, - apinetletv1alpha1.NATGatewayUIDLabel: string(natGateway.UID), - })) - Expect(publicIP.Spec).To(Equal(onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: ipFamily, - })) - - By("asserting the nat gateway does not get an ip address") - Consistently(Object(natGateway)).Should(HaveField("Status.IPs", BeNil())) - - By("patching the public ip spec ips") - basePublicIP := publicIP.DeepCopy() - publicIP.Spec.IP = onmetalapinetv1alpha1.MustParseNewIP("10.0.0.1") - Expect(k8sClient.Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) - - By("patching the public ip status to allocated") - basePublicIP = publicIP.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) - - By("checking that nat gateway contains ip") - Eventually(Object(natGateway)).Should(HaveField("Status.IPs", - ContainElement(networkingv1alpha1.NATGatewayIPStatus{ - Name: ipName, - IP: *commonv1alpha1.MustParseNewIP("10.0.0.1"), - }), - )) - - By("requesting one more ip") - natGatewayBase := natGateway.DeepCopy() - natGateway.Spec.IPs = append(natGateway.Spec.IPs, networkingv1alpha1.NATGatewayIP{ - Name: ipName + "-2", - }) - Expect(k8sClient.Patch(ctx, natGateway, client.MergeFrom(natGatewayBase))).To(Succeed()) - - By("waiting for the corresponding public ip to be created") - publicIP2 := &onmetalapinetv1alpha1.PublicIP{ + By("waiting for the APINet NAT gateway autoscaler to be present") + apiNetNATGatewayAutoscaler := &v1alpha1.NATGatewayAutoscaler{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: fmt.Sprintf("%s-%s-%s", natGateway.UID, ipName+"-2", strings.ToLower(string(ipFamily))), + Namespace: apiNetNs.Name, + Name: string(natGateway.UID), }, } - Eventually(Get(publicIP2)).Should(Succeed()) - - By("patching the second public ip spec ips") - basePublicIP2 := publicIP2.DeepCopy() - publicIP2.Spec.IP = onmetalapinetv1alpha1.MustParseNewIP("10.0.0.2") - Expect(k8sClient.Patch(ctx, publicIP2, client.MergeFrom(basePublicIP2))).To(Succeed()) - - By("patching the second public ip status to allocated") - basePublicIP2 = publicIP2.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP2.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, publicIP2, client.MergeFrom(basePublicIP2))).To(Succeed()) - - By("checking that nat gateway contains ip") - Eventually(Object(natGateway)).Should(HaveField("Status.IPs", - ContainElements( - networkingv1alpha1.NATGatewayIPStatus{ - Name: ipName, - IP: *commonv1alpha1.MustParseNewIP("10.0.0.1"), - }, - networkingv1alpha1.NATGatewayIPStatus{ - Name: ipName + "-2", - IP: *commonv1alpha1.MustParseNewIP("10.0.0.2"), - }), - )) - - By("deleting the nat gateway") - Expect(k8sClient.Delete(ctx, natGateway)).To(Succeed()) - - By("waiting for it to be gone") - Eventually(Get(natGateway)).Should(Satisfy(apierrors.IsNotFound)) - - By("asserting the corresponding public ips are gone as well") - Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(publicIP), publicIP)).To(Satisfy(apierrors.IsNotFound)) - Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(publicIP2), publicIP2)).To(Satisfy(apierrors.IsNotFound)) - }) - - It("should clean up dangling public ips", func() { - By("creating a public ip") - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "public-ip-", - Labels: map[string]string{ - apinetletv1alpha1.NATGatewayNamespaceLabel: ns.Name, - apinetletv1alpha1.NATGatewayNameLabel: "some-name", - apinetletv1alpha1.NATGatewayUIDLabel: "some-uid", - }, - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - - By("waiting for the public ip to be gone") - Eventually(Get(publicIP)).Should(Satisfy(apierrors.IsNotFound)) + Eventually(Object(apiNetNATGatewayAutoscaler)).Should( + SatisfyAll( + HaveField("Labels", apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), natGateway)), + BeControlledBy(apiNetNATGateway), + ), + ) }) }) diff --git a/apinetlet/controllers/network_controller.go b/apinetlet/controllers/network_controller.go index 454147d2..61db1a7b 100644 --- a/apinetlet/controllers/network_controller.go +++ b/apinetlet/controllers/network_controller.go @@ -17,26 +17,22 @@ package controllers import ( "context" "fmt" - "strconv" "github.com/go-logr/logr" "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + "github.com/onmetal/onmetal-api-net/apinetlet/handler" + "github.com/onmetal/onmetal-api-net/apinetlet/provider" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" "github.com/onmetal/onmetal-api/utils/predicates" - corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/event" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" ) @@ -58,6 +54,8 @@ type NetworkReconciler struct { //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=networks/finalizers,verbs=update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=networks/status,verbs=get;update;patch +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networks,verbs=get;list;watch;create;update;patch;delete;deletecollection + func (r *NetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) network := &networkingv1alpha1.Network{} @@ -76,12 +74,9 @@ func (r *NetworkReconciler) deleteGone(ctx context.Context, log logr.Logger, net log.V(1).Info("Delete gone") log.V(1).Info("Deleting any matching apinet networks") - if err := r.APINetClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.Network{}, + if err := r.APINetClient.DeleteAllOf(ctx, &apinetv1alpha1.Network{}, client.InNamespace(r.APINetNamespace), - client.MatchingLabels{ - apinetletv1alpha1.NetworkNamespaceLabel: networkKey.Namespace, - apinetletv1alpha1.NetworkNameLabel: networkKey.Name, - }, + apinetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), networkKey, &networkingv1alpha1.Network{}), ); err != nil { return ctrl.Result{}, fmt.Errorf("error deleting apinet networks: %w", err) } @@ -107,12 +102,13 @@ func (r *NetworkReconciler) delete(ctx context.Context, log logr.Logger, network } log.V(1).Info("Deleting target apinet network if any") - if err := r.APINetClient.Delete(ctx, &onmetalapinetv1alpha1.Network{ + apiNetNetwork := &apinetv1alpha1.Network{ ObjectMeta: metav1.ObjectMeta{ Namespace: r.APINetNamespace, Name: string(network.UID), }, - }); err != nil { + } + if err := r.APINetClient.Delete(ctx, apiNetNetwork); err != nil { if !apierrors.IsNotFound(err) { return ctrl.Result{}, fmt.Errorf("error deleting target apinet network: %w", err) } @@ -151,24 +147,21 @@ func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, netw return ctrl.Result{Requeue: true}, nil } - vni, err := r.applyAPINetNetwork(ctx, log, network) + apiNetNetwork, err := r.applyAPINetNetwork(ctx, log, network) if err != nil { - return ctrl.Result{}, fmt.Errorf("error applying apinet network: %w", err) - } - if vni == nil { - log.V(1).Info("APINet network is not yet allocated, setting network to pending") - if err := r.updateNetworkStatus(ctx, network, networkingv1alpha1.NetworkStatePending); err != nil { - return ctrl.Result{}, fmt.Errorf("error updating network status: %w", err) + if network.Status.State != networkingv1alpha1.NetworkStateAvailable { + if err := r.updateNetworkStatus(ctx, network, networkingv1alpha1.NetworkStatePending); err != nil { + log.Error(err, "Error updating network state") + } } - return ctrl.Result{}, nil + return ctrl.Result{}, fmt.Errorf("error applying apinet network: %w", err) } - - log = log.WithValues("VNI", *vni) - log.V(1).Info("APINet network is allocated") + log = log.WithValues("ID", apiNetNetwork.Spec.ID) + log.V(1).Info("Applied APINet network") if network.Spec.ProviderID == "" { log.V(1).Info("Setting network provider id") - if err := r.setNetworkProviderID(ctx, network, *vni); err != nil { + if err := r.setNetworkProviderID(ctx, network, apiNetNetwork); err != nil { return ctrl.Result{}, fmt.Errorf("error setting network provider id: %w", err) } @@ -185,78 +178,40 @@ func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, netw return ctrl.Result{}, nil } -func (r *NetworkReconciler) setNetworkProviderID(ctx context.Context, network *networkingv1alpha1.Network, vni int32) error { - networkBase := network.DeepCopy() - network.Spec.ProviderID = strconv.FormatInt(int64(vni), 10) - if err := r.Patch(ctx, network, client.MergeFrom(networkBase)); err != nil { +func (r *NetworkReconciler) setNetworkProviderID( + ctx context.Context, + network *networkingv1alpha1.Network, + apiNetNetwork *apinetv1alpha1.Network, +) error { + base := network.DeepCopy() + network.Spec.ProviderID = provider.GetNetworkID(apiNetNetwork.Namespace, apiNetNetwork.Name, apiNetNetwork.Spec.ID, apiNetNetwork.UID) + if err := r.Patch(ctx, network, client.MergeFrom(base)); err != nil { return fmt.Errorf("unable to patch network: %w", err) } return nil } -func isAPINetNetworkAllocated(apiNetNetwork *onmetalapinetv1alpha1.Network) bool { - apiNetNetworkConditions := apiNetNetwork.Status.Conditions - idx := onmetalapinetv1alpha1.NetworkConditionIndex(apiNetNetworkConditions, onmetalapinetv1alpha1.NetworkAllocated) - if idx == -1 || apiNetNetworkConditions[idx].Status != corev1.ConditionTrue { - return false - } - - return apiNetNetwork.Spec.VNI != nil -} - -func (r *NetworkReconciler) applyAPINetNetwork(ctx context.Context, log logr.Logger, network *networkingv1alpha1.Network) (*int32, error) { - var vni *int32 - if providerID := network.Spec.ProviderID; providerID != "" { - v, err := strconv.ParseInt(providerID, 10, 32) - if err != nil { - return nil, fmt.Errorf("error parsing network provider id %s: %w", providerID, err) - } - - vni = pointer.Int32(int32(v)) - } - - apiNetNetwork := &onmetalapinetv1alpha1.Network{ +func (r *NetworkReconciler) applyAPINetNetwork(ctx context.Context, log logr.Logger, network *networkingv1alpha1.Network) (*apinetv1alpha1.Network, error) { + apiNetNetwork := &apinetv1alpha1.Network{ TypeMeta: metav1.TypeMeta{ - APIVersion: onmetalapinetv1alpha1.GroupVersion.String(), + APIVersion: apinetv1alpha1.SchemeGroupVersion.String(), Kind: "Network", }, ObjectMeta: metav1.ObjectMeta{ Namespace: r.APINetNamespace, Name: string(network.UID), - Labels: map[string]string{ - apinetletv1alpha1.NetworkNamespaceLabel: network.Namespace, - apinetletv1alpha1.NetworkNameLabel: network.Name, - apinetletv1alpha1.NetworkUIDLabel: string(network.UID), - }, - }, - Spec: onmetalapinetv1alpha1.NetworkSpec{ - VNI: vni, + Labels: apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), network), }, } - log.V(1).Info("Applying apinet network") - if err := r.APINetClient.Patch(ctx, apiNetNetwork, client.Apply, - client.FieldOwner(apinetletv1alpha1.FieldOwner), - client.ForceOwnership, - ); err != nil { + log.V(1).Info("Applying APINet network") + if err := r.APINetClient.Patch(ctx, apiNetNetwork, client.Apply, fieldOwner, client.ForceOwnership); err != nil { return nil, fmt.Errorf("error applying apinet network: %w", err) } - log.V(1).Info("Applied apinet network") - - if !isAPINetNetworkAllocated(apiNetNetwork) { - return nil, nil - } - return apiNetNetwork.Spec.VNI, nil -} - -var apiNetNetworkAllocationChanged = predicate.Funcs{ - UpdateFunc: func(event event.UpdateEvent) bool { - oldAPINetNetwork, newAPINetNetwork := event.ObjectOld.(*onmetalapinetv1alpha1.Network), event.ObjectNew.(*onmetalapinetv1alpha1.Network) - return isAPINetNetworkAllocated(oldAPINetNetwork) != isAPINetNetworkAllocated(newAPINetNetwork) - }, + return apiNetNetwork, nil } -func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster cluster.Cluster) error { +func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCache cache.Cache) error { log := ctrl.Log.WithName("network").WithName("setup") return ctrl.NewControllerManagedBy(mgr). @@ -268,29 +223,8 @@ func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster clu ), ). WatchesRawSource( - source.Kind(apiNetCluster.GetCache(), &onmetalapinetv1alpha1.Network{}), - handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { - apiNetNetwork := obj.(*onmetalapinetv1alpha1.Network) - - if apiNetNetwork.Namespace != r.APINetNamespace { - return nil - } - - namespace, ok := apiNetNetwork.Labels[apinetletv1alpha1.NetworkNamespaceLabel] - if !ok { - return nil - } - - name, ok := apiNetNetwork.Labels[apinetletv1alpha1.NetworkNameLabel] - if !ok { - return nil - } - - return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: namespace, Name: name}}} - }), - builder.WithPredicates( - apiNetNetworkAllocationChanged, - ), + source.Kind(apiNetCache, &apinetv1alpha1.Network{}), + handler.EnqueueRequestForSource(mgr.GetScheme(), mgr.GetRESTMapper(), &networkingv1alpha1.Network{}), ). Complete(r) } diff --git a/apinetlet/controllers/network_controller_test.go b/apinetlet/controllers/network_controller_test.go index 1537d723..80574adc 100644 --- a/apinetlet/controllers/network_controller_test.go +++ b/apinetlet/controllers/network_controller_test.go @@ -15,28 +15,25 @@ package controllers import ( - "strconv" - - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + "github.com/onmetal/onmetal-api-net/apinetlet/provider" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" ) var _ = Describe("NetworkController", func() { - ctx := SetupContext() - ns := SetupTest(ctx) - const vni int32 = 4 + ns := SetupNamespace(&k8sClient) + apiNetNs := SetupNamespace(&k8sClient) + SetupTest(apiNetNs) - It("should allocate an apinet network", func() { + It("should allocate an APINet network", func(ctx SpecContext) { By("creating a network") network := &networkingv1alpha1.Network{ ObjectMeta: metav1.ObjectMeta{ @@ -46,47 +43,30 @@ var _ = Describe("NetworkController", func() { } Expect(k8sClient.Create(ctx, network)).To(Succeed()) - By("waiting for the corresponding apinet network to be created") - apiNetNetwork := &onmetalapinetv1alpha1.Network{ + By("waiting for the corresponding APINet network to be created") + apiNetNetwork := &v1alpha1.Network{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, + Namespace: apiNetNs.Name, Name: string(network.UID), }, } Eventually(Get(apiNetNetwork)).Should(Succeed()) By("inspecting the created apinet network") - Expect(apiNetNetwork.Labels).To(Equal(map[string]string{ - apinetletv1alpha1.NetworkNamespaceLabel: network.Namespace, - apinetletv1alpha1.NetworkNameLabel: network.Name, - apinetletv1alpha1.NetworkUIDLabel: string(network.UID), - })) - Expect(apiNetNetwork.Spec).To(Equal(onmetalapinetv1alpha1.NetworkSpec{})) - - By("asserting the network does not report a vni") - Consistently(Object(network)). - Should(SatisfyAll( - HaveField("Spec.ProviderID", ""), - HaveField("Status.State", Not(Equal(networkingv1alpha1.NetworkStateAvailable))), - )) - - By("setting the apinet network spec vni") - baseAPINetNetwork := apiNetNetwork.DeepCopy() - apiNetNetwork.Spec.VNI = pointer.Int32(vni) - Expect(k8sClient.Patch(ctx, apiNetNetwork, client.MergeFrom(baseAPINetNetwork))).To(Succeed()) - - By("setting the apinet network status to allocated") - baseAPINetNetwork = apiNetNetwork.DeepCopy() - onmetalapinetv1alpha1.SetNetworkCondition(&apiNetNetwork.Status.Conditions, onmetalapinetv1alpha1.NetworkCondition{ - Type: onmetalapinetv1alpha1.NetworkAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, apiNetNetwork, client.MergeFrom(baseAPINetNetwork))).To(Succeed()) + Expect(apiNetNetwork.Labels).To(Equal( + apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), network), + )) + Expect(apiNetNetwork.Spec.ID).NotTo(BeEmpty()) By("waiting for the network to reflect the allocated vni") Eventually(Object(network)). Should(SatisfyAll( - HaveField("Spec.ProviderID", Equal(strconv.FormatInt(int64(vni), 10))), + HaveField("Spec.ProviderID", Equal(provider.GetNetworkID( + apiNetNetwork.Namespace, + apiNetNetwork.Name, + apiNetNetwork.Spec.ID, + apiNetNetwork.UID, + ))), HaveField("Status.State", Equal(networkingv1alpha1.NetworkStateAvailable)), )) @@ -100,48 +80,27 @@ var _ = Describe("NetworkController", func() { Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(apiNetNetwork), apiNetNetwork)).To(Satisfy(apierrors.IsNotFound)) }) - It("should clean up dangling apinet networks", func() { + It("should clean up dangling apinet networks", func(ctx SpecContext) { By("creating a apinet network") - apiNetNetwork := &onmetalapinetv1alpha1.Network{ + apiNetNetwork := &v1alpha1.Network{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, + Namespace: apiNetNs.Name, GenerateName: "apinet-network-", - Labels: map[string]string{ - apinetletv1alpha1.NetworkNamespaceLabel: ns.Name, - apinetletv1alpha1.NetworkNameLabel: "some-name", - apinetletv1alpha1.NetworkUIDLabel: "some-uid", - }, + Labels: apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), + &networkingv1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: "should-not-exist", + UID: "some-uid", + }, + }, + ), }, - Spec: onmetalapinetv1alpha1.NetworkSpec{}, + Spec: v1alpha1.NetworkSpec{}, } Expect(k8sClient.Create(ctx, apiNetNetwork)).To(Succeed()) By("waiting for the apinet network to be gone") Eventually(Get(apiNetNetwork)).Should(Satisfy(apierrors.IsNotFound)) }) - - It("should use the specified provider ID as vni if any", func() { - By("creating a network with provider ID") - vni := int32(42) - network := &networkingv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", - }, - Spec: networkingv1alpha1.NetworkSpec{ - ProviderID: strconv.FormatInt(int64(vni), 10), - }, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - By("waiting for the corresponding apinet network to be created with correct vni") - apiNetNetwork := &onmetalapinetv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: string(network.UID), - }, - } - - Eventually(Object(apiNetNetwork)).Should(HaveField("Spec.VNI", Equal(&vni))) - }) }) diff --git a/apinetlet/controllers/networkinterface_controller.go b/apinetlet/controllers/networkinterface_controller.go new file mode 100644 index 00000000..e5bdf679 --- /dev/null +++ b/apinetlet/controllers/networkinterface_controller.go @@ -0,0 +1,575 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "errors" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/controller-utils/clientutils" + "github.com/onmetal/controller-utils/metautils" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + apinetlethandler "github.com/onmetal/onmetal-api-net/apinetlet/handler" + "github.com/onmetal/onmetal-api-net/apinetlet/provider" + utilgeneric "github.com/onmetal/onmetal-api-net/utils/generic" + commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1" + networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + "github.com/onmetal/onmetal-api/utils/claimmanager" + "github.com/onmetal/onmetal-api/utils/generic" + "github.com/onmetal/onmetal-api/utils/predicates" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/sets" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +const ( + networkInterfaceFinalizer = "apinet.api.onmetal.de/networkinterface" +) + +type NetworkInterfaceReconciler struct { + client.Client + APINetClient client.Client + APINetNamespace string + + WatchFilterValue string +} + +//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch +//+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=networkinterfaces,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=networkinterfaces/finalizers,verbs=update;patch +//+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=networkinterfaces/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=virtualips,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=ipam.api.onmetal.de,resources=prefix,verbs=get;list;watch + +//+cluster=apinet:kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkinterfaces,verbs=get;list;watch;update;patch + +func (r *NetworkInterfaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + nic := &networkingv1alpha1.NetworkInterface{} + if err := r.Get(ctx, req.NamespacedName, nic); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, err + } + + if err := r.releaseNetworkInterfaceKeyAPINetInterfaces(ctx, req.NamespacedName); err != nil { + return ctrl.Result{}, fmt.Errorf("error releasing apinet network interfaces by key: %w", err) + } + return ctrl.Result{}, nil + } + + return r.reconcileExists(ctx, log, nic) +} + +func (r *NetworkInterfaceReconciler) reconcileExists(ctx context.Context, log logr.Logger, nic *networkingv1alpha1.NetworkInterface) (ctrl.Result, error) { + if !nic.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, nic) + } + return r.reconcile(ctx, log, nic) +} + +func (r *NetworkInterfaceReconciler) releaseNetworkInterfaceKeyAPINetInterfaces(ctx context.Context, nicKey client.ObjectKey) error { + apiNetNicList := &apinetv1alpha1.NetworkInterfaceList{} + if err := r.APINetClient.List(ctx, apiNetNicList, + client.InNamespace(r.APINetNamespace), + apinetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), nicKey, &networkingv1alpha1.NetworkInterface{}), + ); err != nil { + return fmt.Errorf("error listing apinet network interfaces: %w", err) + } + + var errs []error + for _, apiNetNic := range apiNetNicList.Items { + if err := r.releaseAPINetNetworkInterface(ctx, &apiNetNic); client.IgnoreNotFound(err) != nil { + errs = append(errs, err) + } + } + return errors.Join(errs...) +} + +func (r *NetworkInterfaceReconciler) releaseAPINetNetworkInterface(ctx context.Context, apiNetNic *apinetv1alpha1.NetworkInterface) error { + keys := apinetletclient.SourceLabelKeys(r.Scheme(), r.RESTMapper(), &networkingv1alpha1.NetworkInterface{}) + base := apiNetNic.DeepCopy() + metautils.DeleteLabels(apiNetNic, keys) + return r.APINetClient.Patch(ctx, apiNetNic, client.StrategicMergeFrom(base)) +} + +func (r *NetworkInterfaceReconciler) releaseNetworkInterfaceAPINetNetworkInterfaces(ctx context.Context, nic *networkingv1alpha1.NetworkInterface) error { + apiNetNicList := &apinetv1alpha1.NetworkInterfaceList{} + if err := r.APINetClient.List(ctx, apiNetNicList, + client.InNamespace(r.APINetNamespace), + apinetletclient.MatchingSourceLabels(r.Scheme(), r.RESTMapper(), nic), + ); err != nil { + return fmt.Errorf("error listing apinet network interfaces: %w", err) + } + + var ( + strat = &apiNetNetworkInterfaceClaimStrategy{r.Client} + claimMgr = claimmanager.New(asNonDeletingObject{nic}, claimmanager.NothingSelector(), strat) + errs []error + ) + for _, apiNetNic := range apiNetNicList.Items { + _, err := claimMgr.Claim(ctx, &apiNetNic) + if err != nil { + errs = append(errs, err) + } + } + return errors.Join(errs...) +} + +func (r *NetworkInterfaceReconciler) delete(ctx context.Context, log logr.Logger, nic *networkingv1alpha1.NetworkInterface) (ctrl.Result, error) { + log.V(1).Info("Delete") + if !controllerutil.ContainsFinalizer(nic, networkInterfaceFinalizer) { + log.V(1).Info("No finalizer present, nothing to do") + return ctrl.Result{}, nil + } + + if err := r.releaseNetworkInterfaceAPINetNetworkInterfaces(ctx, nic); err != nil { + return ctrl.Result{}, fmt.Errorf("error releasing apinet network interfaces: %w", err) + } + log.V(1).Info("Released APINet network interfaces") + + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, nic, networkInterfaceFinalizer); err != nil { + return ctrl.Result{}, err + } + log.V(1).Info("Removed finalizer") + + log.V(1).Info("Deleted") + return ctrl.Result{}, nil +} + +func (r *NetworkInterfaceReconciler) networkInterfaceVirtualIPSelector(nic *networkingv1alpha1.NetworkInterface) claimmanager.Selector { + vipNames := sets.New[string]() + if vipSrc := nic.Spec.VirtualIP; vipSrc != nil { + name := networkingv1alpha1.NetworkInterfaceVirtualIPName(nic.Name, *vipSrc) + vipNames.Insert(name) + } + return claimmanager.SelectorFunc(func(obj client.Object) bool { + vip := obj.(*networkingv1alpha1.VirtualIP) + return vipNames.Has(vip.Name) + }) +} + +type apiNetNetworkInterfaceClaimStrategy struct { + client.Client +} + +func (s *apiNetNetworkInterfaceClaimStrategy) ClaimState(claimer client.Object, obj client.Object) claimmanager.ClaimState { + apiNetNic := obj.(*apinetv1alpha1.NetworkInterface) + if data := apinetletclient.SourceObjectDataFromObject(s.Scheme(), s.RESTMapper(), claimer, apiNetNic); data != nil { + if data.UID == claimer.GetUID() { + return claimmanager.ClaimStateClaimed + } + return claimmanager.ClaimStateTaken + } + return claimmanager.ClaimStateFree +} + +func (s *apiNetNetworkInterfaceClaimStrategy) Adopt(ctx context.Context, claimer client.Object, obj client.Object) error { + apiNetNic := obj.(*apinetv1alpha1.NetworkInterface) + base := apiNetNic.DeepCopy() + metautils.SetLabels(apiNetNic, apinetletclient.SourceLabels(s.Scheme(), s.RESTMapper(), claimer)) + return s.Patch(ctx, apiNetNic, client.StrategicMergeFrom(base)) +} + +func (s *apiNetNetworkInterfaceClaimStrategy) Release(ctx context.Context, claimer client.Object, obj client.Object) error { + apiNetNic := obj.(*apinetv1alpha1.NetworkInterface) + base := apiNetNic.DeepCopy() + keys := apinetletclient.SourceLabelKeys(s.Scheme(), s.RESTMapper(), claimer) + metautils.DeleteLabels(apiNetNic, keys) + apiNetNic.Spec.PublicIPs = nil + apiNetNic.Spec.Prefixes = nil + return s.Patch(ctx, apiNetNic, client.StrategicMergeFrom(base)) +} + +type virtualIPClaimStrategy struct { + client.Client +} + +func (s *virtualIPClaimStrategy) ClaimState(claimer client.Object, obj client.Object) claimmanager.ClaimState { + vip := obj.(*networkingv1alpha1.VirtualIP) + if targetRef := vip.Spec.TargetRef; targetRef != nil { + if targetRef.UID == claimer.GetUID() { + return claimmanager.ClaimStateClaimed + } + return claimmanager.ClaimStateTaken + } + return claimmanager.ClaimStateFree +} + +func (s *virtualIPClaimStrategy) Adopt(ctx context.Context, claimer client.Object, obj client.Object) error { + vip := obj.(*networkingv1alpha1.VirtualIP) + base := vip.DeepCopy() + vip.Spec.TargetRef = &commonv1alpha1.LocalUIDReference{ + Name: claimer.GetName(), + UID: claimer.GetUID(), + } + return s.Patch(ctx, vip, client.StrategicMergeFrom(base)) +} + +func (s *virtualIPClaimStrategy) Release(ctx context.Context, claimer client.Object, obj client.Object) error { + vip := obj.(*networkingv1alpha1.VirtualIP) + base := vip.DeepCopy() + vip.Spec.TargetRef = nil + return s.Patch(ctx, vip, client.StrategicMergeFrom(base)) +} + +func (r *NetworkInterfaceReconciler) getVirtualIPsForNetworkInterface(ctx context.Context, nic *networkingv1alpha1.NetworkInterface) ([]networkingv1alpha1.VirtualIP, error) { + vipList := &networkingv1alpha1.VirtualIPList{} + if err := r.List(ctx, vipList, + client.InNamespace(nic.Namespace), + ); err != nil { + return nil, fmt.Errorf("error listing virtual IPs: %w", err) + } + + var ( + sel = r.networkInterfaceVirtualIPSelector(nic) + strategy = &virtualIPClaimStrategy{r.Client} + claimMgr = claimmanager.New(nic, sel, strategy) + vips []networkingv1alpha1.VirtualIP + errs []error + ) + for _, vip := range vipList.Items { + ok, err := claimMgr.Claim(ctx, &vip) + if err != nil { + errs = append(errs, err) + continue + } + if !ok { + continue + } + + vips = append(vips, vip) + } + return vips, errors.Join(errs...) +} + +func (r *NetworkInterfaceReconciler) networkInterfaceAPINetNetworkInterfaceSelector(nic *networkingv1alpha1.NetworkInterface) claimmanager.Selector { + _, _, _, nicUID, err := provider.ParseNetworkInterfaceID(nic.Spec.ProviderID) + if err != nil { + return claimmanager.NothingSelector() + } + + return claimmanager.SelectorFunc(func(obj client.Object) bool { + apiNetNic := obj.(*apinetv1alpha1.NetworkInterface) + return apiNetNic.UID == nicUID + }) +} + +func (r *NetworkInterfaceReconciler) getAPINetNetworkInterfaceForNetworkInterface(ctx context.Context, nic *networkingv1alpha1.NetworkInterface) (*apinetv1alpha1.NetworkInterface, error) { + apiNetNicList := &apinetv1alpha1.NetworkInterfaceList{} + if err := r.APINetClient.List(ctx, apiNetNicList, + client.InNamespace(r.APINetNamespace), + ); err != nil { + return nil, fmt.Errorf("error listing apinet network interfaces: %w", err) + } + + var ( + sel = r.networkInterfaceAPINetNetworkInterfaceSelector(nic) + claimMgr = claimmanager.New(nic, sel, &apiNetNetworkInterfaceClaimStrategy{r.Client}) + foundAPINetNic *apinetv1alpha1.NetworkInterface + errs []error + ) + for _, apiNetNic := range apiNetNicList.Items { + ok, err := claimMgr.Claim(ctx, &apiNetNic) + if err != nil { + errs = append(errs, err) + continue + } + if !ok { + continue + } + + foundAPINetNic = generic.Pointer(apiNetNic) + } + return foundAPINetNic, errors.Join(errs...) +} + +func (r *NetworkInterfaceReconciler) getPrefixesForNetworkInterface( + ctx context.Context, + nic *networkingv1alpha1.NetworkInterface, +) ([]net.IPPrefix, error) { + var res []net.IPPrefix + for idx, prefixSrc := range nic.Spec.Prefixes { + switch { + case prefixSrc.Value != nil: + res = append(res, net.IPPrefix{Prefix: prefixSrc.Value.Prefix}) + case prefixSrc.Ephemeral != nil: + ipamPrefix := &ipamv1alpha1.Prefix{} + ipamPrefixKey := client.ObjectKey{Namespace: nic.Namespace, Name: networkingv1alpha1.NetworkInterfacePrefixIPAMPrefixName(nic.Name, idx)} + if err := r.Get(ctx, ipamPrefixKey, ipamPrefix); err != nil { + if !apierrors.IsNotFound(err) { + return nil, err + } + continue + } + + if ipamPrefix.Status.Phase != ipamv1alpha1.PrefixPhaseAllocated { + continue + } + + res = append(res, net.IPPrefix{Prefix: ipamPrefix.Spec.Prefix.Prefix}) + } + } + return res, nil +} + +func (r *NetworkInterfaceReconciler) manageAPINetNetworkInterface( + ctx context.Context, + nic *networkingv1alpha1.NetworkInterface, + apiNetNic *apinetv1alpha1.NetworkInterface, + vips []networkingv1alpha1.VirtualIP, + prefixes []net.IPPrefix, +) error { + _ = nic + + var ( + publicIPs []apinetv1alpha1.NetworkInterfacePublicIP + publicIPFamilies = sets.New[corev1.IPFamily]() + ) + for _, vip := range vips { + if ip := vip.Status.IP; ip.IsValid() { + publicIPFamilies.Insert(ip.Family()) + publicIPs = append(publicIPs, apinetv1alpha1.NetworkInterfacePublicIP{ + Name: ip.String(), + IPFamily: ip.Family(), + IP: net.IP{Addr: ip.Addr}, + }) + } + } + filteredNATs := utilslices.FilterFunc(apiNetNic.Spec.NATs, + func(nat apinetv1alpha1.NetworkInterfaceNAT) bool { + return !publicIPFamilies.Has(nat.IPFamily) + }, + ) + + if slices.Equal(apiNetNic.Spec.PublicIPs, publicIPs) && + slices.Equal(apiNetNic.Spec.Prefixes, prefixes) && + slices.Equal(apiNetNic.Spec.NATs, filteredNATs) { + return nil + } + + base := apiNetNic.DeepCopy() + apiNetNic.Spec.PublicIPs = publicIPs + apiNetNic.Spec.NATs = filteredNATs + apiNetNic.Spec.Prefixes = prefixes + return r.APINetClient.Patch(ctx, apiNetNic, client.StrategicMergeFrom(base)) +} + +func (r *NetworkInterfaceReconciler) setNetworkInterfacePending( + ctx context.Context, + nic *networkingv1alpha1.NetworkInterface, +) error { + now := metav1.Now() + + base := nic.DeepCopy() + nic.Status.VirtualIP = nil + nic.Status.IPs = nil + nic.Status.Prefixes = nil + if nic.Status.State != networkingv1alpha1.NetworkInterfaceStatePending { + nic.Status.LastStateTransitionTime = &now + } + nic.Status.State = networkingv1alpha1.NetworkInterfaceStatePending + + return r.Status().Patch(ctx, nic, client.StrategicMergeFrom(base)) +} + +func (r *NetworkInterfaceReconciler) reconcile(ctx context.Context, log logr.Logger, nic *networkingv1alpha1.NetworkInterface) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, nic, networkInterfaceFinalizer) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error ensuring finalizer: %w", err) + } + if modified { + log.V(1).Info("Added finalizer, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("Finalizer is present") + + var errs []error + + apiNetNic, err := r.getAPINetNetworkInterfaceForNetworkInterface(ctx, nic) + if err != nil { + errs = append(errs, err) + } + + vips, err := r.getVirtualIPsForNetworkInterface(ctx, nic) + if err != nil { + errs = append(errs, err) + } + + prefixes, err := r.getPrefixesForNetworkInterface(ctx, nic) + if err != nil { + errs = append(errs, err) + } + + if err := errors.Join(errs...); err != nil { + return ctrl.Result{}, fmt.Errorf("error getting APINet network interface for network interface: %w", err) + } + + if apiNetNic == nil { + if err := r.setNetworkInterfacePending(ctx, nic); err != nil { + return ctrl.Result{}, fmt.Errorf("error setting network interface to pending: %w", err) + } + log.V(1).Info("Set network interface to pending") + return ctrl.Result{}, nil + } + + if err := r.manageAPINetNetworkInterface(ctx, nic, apiNetNic, vips, prefixes); err != nil { + return ctrl.Result{}, fmt.Errorf("error managing apinet network interface: %w", err) + } + + var ( + expectedState = apiNetNetworkInterfaceStateToNetworkInterfaceState(apiNetNic.Status.State) + expectedIPs = apiNetIPsToIPs(apiNetNic.Spec.IPs) + expectedPrefixes = apiNetIPPrefixesToIPPrefixes(apiNetNic.Spec.Prefixes) + expectedVirtualIP = WorkaroundOnlyV4VirtualIPs(apiNetIPsToIPs(apiNetNic.Status.PublicIPs)) + ) + if !NetworkInterfaceStatusUpToDate(nic, expectedState, expectedIPs, expectedPrefixes, expectedVirtualIP) { + if err := r.updateNetworkInterfaceStatus(ctx, nic, expectedState, expectedIPs, expectedPrefixes, expectedVirtualIP); err != nil { + return ctrl.Result{}, fmt.Errorf("error updating network interface status: %w", err) + } + log.V(1).Info("Updated network interface status") + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *NetworkInterfaceReconciler) updateNetworkInterfaceStatus( + ctx context.Context, + nic *networkingv1alpha1.NetworkInterface, + state networkingv1alpha1.NetworkInterfaceState, + ips []commonv1alpha1.IP, + prefixes []commonv1alpha1.IPPrefix, + virtualIP *commonv1alpha1.IP, +) error { + now := metav1.Now() + base := nic.DeepCopy() + + if nic.Status.State != state { + nic.Status.LastStateTransitionTime = &now + } + nic.Status.State = state + nic.Status.IPs = ips + nic.Status.Prefixes = prefixes + nic.Status.VirtualIP = virtualIP + + if err := r.Status().Patch(ctx, nic, client.StrategicMergeFrom(base)); err != nil { + return fmt.Errorf("error patching status: %w", err) + } + return nil +} + +func NetworkInterfaceStatusUpToDate( + nic *networkingv1alpha1.NetworkInterface, + expectedState networkingv1alpha1.NetworkInterfaceState, + expectedIPs []commonv1alpha1.IP, + expectedIPPrefixes []commonv1alpha1.IPPrefix, + expectedVirtualIP *commonv1alpha1.IP, +) bool { + return nic.Status.State == expectedState && + slices.Equal(nic.Status.IPs, expectedIPs) && + slices.Equal(nic.Status.Prefixes, expectedIPPrefixes) && + utilgeneric.EqualPointers(nic.Status.VirtualIP, expectedVirtualIP) +} + +func WorkaroundOnlyV4VirtualIPs(ips []commonv1alpha1.IP) *commonv1alpha1.IP { + for i := range ips { + ip := &ips[i] + if ip.Family() == corev1.IPv4Protocol { + return ip + } + } + return nil +} + +func (r *NetworkInterfaceReconciler) enqueueByVirtualIP() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + vip := obj.(*networkingv1alpha1.VirtualIP) + targetRef := vip.Spec.TargetRef + if targetRef == nil { + return nil + } + return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: vip.Namespace, Name: targetRef.Name}}} + }) +} + +func (r *NetworkInterfaceReconciler) enqueueByNetworkInterfaceVirtualIPSelection() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + vip := obj.(*networkingv1alpha1.VirtualIP) + log := ctrl.LoggerFrom(ctx) + + nicList := &networkingv1alpha1.NetworkInterfaceList{} + if err := r.List(ctx, nicList, + client.InNamespace(vip.Namespace), + ); err != nil { + log.Error(err, "Error listing network interfaces") + return nil + } + + var reqs []ctrl.Request + for _, nic := range nicList.Items { + sel := r.networkInterfaceVirtualIPSelector(&nic) + if sel.Match(vip) { + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&nic)}) + } + } + + return reqs + }) +} + +func (r *NetworkInterfaceReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCache cache.Cache) error { + log := ctrl.Log.WithName("networkinterface").WithName("setup") + return ctrl.NewControllerManagedBy(mgr). + For( + &networkingv1alpha1.NetworkInterface{}, + builder.WithPredicates( + predicates.ResourceHasFilterLabel(log, r.WatchFilterValue), + predicates.ResourceIsNotExternallyManaged(log), + ), + ). + WatchesRawSource( + source.Kind(apiNetCache, &apinetv1alpha1.NetworkInterface{}), + apinetlethandler.EnqueueRequestForSource(r.Scheme(), r.RESTMapper(), &networkingv1alpha1.NetworkInterface{}), + ). + Owns(&ipamv1alpha1.Prefix{}). + Watches( + &networkingv1alpha1.VirtualIP{}, + r.enqueueByVirtualIP(), + builder.WithPredicates(virtualIPClaimedPredicate()), + ). + Watches( + &networkingv1alpha1.VirtualIP{}, + r.enqueueByNetworkInterfaceVirtualIPSelection(), + builder.WithPredicates(virtualIPFreePredicate()), + ). + Complete(r) +} diff --git a/apinetlet/controllers/networkinterface_controller_test.go b/apinetlet/controllers/networkinterface_controller_test.go new file mode 100644 index 00000000..c6876bad --- /dev/null +++ b/apinetlet/controllers/networkinterface_controller_test.go @@ -0,0 +1,106 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + "github.com/onmetal/onmetal-api-net/apinetlet/provider" + commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" + networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("NetworkInterfaceController", func() { + ns := SetupNamespace(&k8sClient) + apiNetNs := SetupNamespace(&k8sClient) + SetupTest(apiNetNs) + network, apiNetNetwork := SetupNetwork(ns, apiNetNs) + + It("should claim and reconcile the network interface", func(ctx SpecContext) { + By("creating a virtual IP") + vip := &networkingv1alpha1.VirtualIP{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "vip-", + }, + Spec: networkingv1alpha1.VirtualIPSpec{ + Type: networkingv1alpha1.VirtualIPTypePublic, + IPFamily: corev1.IPv4Protocol, + }, + } + Expect(k8sClient.Create(ctx, vip)).To(Succeed()) + + By("waiting for the virtual IP report an IP") + Eventually(Object(vip)).Should(HaveField("Status.IP", Not(BeNil()))) + publicIP := *vip.Status.IP + + By("creating an apinet network interface") + apiNetNic := &apinetv1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: apiNetNs.Name, + GenerateName: "apinet-nic-", + }, + Spec: apinetv1alpha1.NetworkInterfaceSpec{ + NetworkRef: corev1.LocalObjectReference{Name: apiNetNetwork.Name}, + IPs: []net.IP{net.MustParseIP("192.168.178.1")}, + }, + } + Expect(k8sClient.Create(ctx, apiNetNic)).To(Succeed()) + + By("creating a network interface") + nic := &networkingv1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nic-", + }, + Spec: networkingv1alpha1.NetworkInterfaceSpec{ + ProviderID: provider.GetNetworkInterfaceID(apiNetNs.Name, apiNetNic.Name, "node", apiNetNic.UID), + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPFamilies: []corev1.IPFamily{corev1.IPv4Protocol}, + IPs: []networkingv1alpha1.IPSource{ + {Value: commonv1alpha1.MustParseNewIP("192.168.178.1")}, + }, + VirtualIP: &networkingv1alpha1.VirtualIPSource{ + VirtualIPRef: &corev1.LocalObjectReference{Name: vip.Name}, + }, + }, + } + Expect(k8sClient.Create(ctx, nic)).To(Succeed()) + + By("waiting for the APINet network interface to be claimed") + Eventually(Object(apiNetNic)).Should(SatisfyAll( + HaveField("Spec.PublicIPs", ConsistOf(HaveField("IP", net.IP{Addr: publicIP.Addr}))), + WithTransform(func(apiNetNic *apinetv1alpha1.NetworkInterface) *apinetletclient.SourceObjectData { + return apinetletclient.SourceObjectDataFromObject( + k8sClient.Scheme(), + k8sClient.RESTMapper(), + nic, + apiNetNic, + ) + }, Equal(&apinetletclient.SourceObjectData{ + Namespace: nic.Namespace, + Name: nic.Name, + UID: nic.UID, + }))), + ) + }) +}) diff --git a/apinetlet/controllers/virtualip_controller.go b/apinetlet/controllers/virtualip_controller.go index 87670810..69db02b2 100644 --- a/apinetlet/controllers/virtualip_controller.go +++ b/apinetlet/controllers/virtualip_controller.go @@ -21,8 +21,11 @@ import ( "github.com/go-logr/logr" "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + "github.com/onmetal/onmetal-api-net/apinetlet/handler" + apinetv1alpha1ac "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" "github.com/onmetal/onmetal-api/utils/predicates" @@ -30,10 +33,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/source" ) @@ -43,7 +45,8 @@ const ( type VirtualIPReconciler struct { client.Client - APINetClient client.Client + APINetClient client.Client + APINetInterface onmetalapinet.Interface APINetNamespace string @@ -54,8 +57,8 @@ type VirtualIPReconciler struct { //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=virtualips,verbs=get;list;watch;update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=virtualips/finalizers,verbs=update;patch //+kubebuilder:rbac:groups=networking.api.onmetal.de,resources=virtualips/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips/status,verbs=get + +//+cluster=apinet:kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=ips,verbs=get;list;watch;create;update;patch;delete;deletecollection func (r *VirtualIPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) @@ -74,18 +77,15 @@ func (r *VirtualIPReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( func (r *VirtualIPReconciler) deleteGone(ctx context.Context, log logr.Logger, virtualIPKey client.ObjectKey) (ctrl.Result, error) { log.V(1).Info("Delete gone") - log.V(1).Info("Deleting any matching apinet public ips") - if err := r.APINetClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.PublicIP{}, + log.V(1).Info("Deleting any matching APINet ips") + if err := r.APINetClient.DeleteAllOf(ctx, &apinetv1alpha1.IP{}, client.InNamespace(r.APINetNamespace), - client.MatchingLabels{ - apinetletv1alpha1.VirtualIPNamespaceLabel: virtualIPKey.Namespace, - apinetletv1alpha1.VirtualIPNameLabel: virtualIPKey.Name, - }, + apinetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), virtualIPKey, &networkingv1alpha1.VirtualIP{}), ); err != nil { - return ctrl.Result{}, fmt.Errorf("error deleting apinet public ips: %w", err) + return ctrl.Result{}, fmt.Errorf("error deleting apinet ips: %w", err) } - log.V(1).Info("Issued delete for any leftover apinet public ip") + log.V(1).Info("Issued delete for any leftover APINet ips") return ctrl.Result{}, nil } @@ -109,18 +109,19 @@ func (r *VirtualIPReconciler) delete(ctx context.Context, log logr.Logger, virtu return ctrl.Result{}, nil } - log.V(1).Info("Deleting target public ip if any") - if err := r.APINetClient.Delete(ctx, &onmetalapinetv1alpha1.PublicIP{ + log.V(1).Info("Deleting target APINet IP if any") + apiNetIP := &apinetv1alpha1.IP{ ObjectMeta: metav1.ObjectMeta{ Namespace: r.APINetNamespace, Name: string(virtualIP.UID), }, - }); err != nil { + } + if err := r.APINetClient.Delete(ctx, apiNetIP); err != nil { if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error deleting target public ip: %w", err) + return ctrl.Result{}, fmt.Errorf("error deleting target apinet ip: %w", err) } - log.V(1).Info("Target public ip is gone, removing finalizer") + log.V(1).Info("Target APINet ip is gone, removing finalizer") if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, virtualIP, virtualIPFinalizer); err != nil { return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) } @@ -128,7 +129,7 @@ func (r *VirtualIPReconciler) delete(ctx context.Context, log logr.Logger, virtu return ctrl.Result{}, nil } - log.V(1).Info("Target public ip is not yet gone, requeueing") + log.V(1).Info("Target APINet ip is not yet gone, requeueing") return ctrl.Result{Requeue: true}, nil } @@ -145,23 +146,16 @@ func (r *VirtualIPReconciler) reconcile(ctx context.Context, log logr.Logger, vi return ctrl.Result{Requeue: true}, nil } - ip, err := r.applyPublicIP(ctx, log, virtualIP) + ip, err := r.applyIP(ctx, log, virtualIP) if err != nil { - return ctrl.Result{}, fmt.Errorf("error getting / applying public ip: %w", err) - } - if !ip.IsValid() { - log.V(1).Info("Public ip is not yet allocated, patching status") - if err := r.patchStatusUnallocated(ctx, virtualIP); err != nil { - return ctrl.Result{}, err + if virtualIP.Status.IP == nil { + if err := r.patchStatusUnallocated(ctx, virtualIP); err != nil { + log.Error(err, "Error patching virtual IP status") + } } - log.V(1).Info("Patched virtual ip status") - return ctrl.Result{}, nil + return ctrl.Result{}, fmt.Errorf("error applying apinet ip: %w", err) } - log = log.WithValues("IP", ip) - log.V(1).Info("Public ip is allocated") - - log.V(1).Info("Patching virtual ip status ip allocated") if err := r.patchStatusAllocated(ctx, virtualIP, ip); err != nil { return ctrl.Result{}, fmt.Errorf("error patching virtual ip status") } @@ -169,46 +163,31 @@ func (r *VirtualIPReconciler) reconcile(ctx context.Context, log logr.Logger, vi return ctrl.Result{}, nil } -func (r *VirtualIPReconciler) applyPublicIP(ctx context.Context, log logr.Logger, virtualIP *networkingv1alpha1.VirtualIP) (netip.Addr, error) { - apiNetPublicIP := &onmetalapinetv1alpha1.PublicIP{ - TypeMeta: metav1.TypeMeta{ - APIVersion: onmetalapinetv1alpha1.GroupVersion.String(), - Kind: "PublicIP", - }, - ObjectMeta: metav1.ObjectMeta{ - Namespace: r.APINetNamespace, - Name: string(virtualIP.UID), - Labels: map[string]string{ - apinetletv1alpha1.VirtualIPNamespaceLabel: virtualIP.Namespace, - apinetletv1alpha1.VirtualIPNameLabel: virtualIP.Name, - apinetletv1alpha1.VirtualIPUIDLabel: string(virtualIP.UID), - }, - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: virtualIP.Spec.IPFamily, - }, - } - - log.V(1).Info("Applying apinet public ip") - if err := r.APINetClient.Patch(ctx, apiNetPublicIP, client.Apply, - client.FieldOwner(apinetletv1alpha1.FieldOwner), - client.ForceOwnership, - ); err != nil { - return netip.Addr{}, fmt.Errorf("error applying apinet public ip: %w", err) +func (r *VirtualIPReconciler) applyIP(ctx context.Context, log logr.Logger, virtualIP *networkingv1alpha1.VirtualIP) (netip.Addr, error) { + apiNetIPApplyCfg := + apinetv1alpha1ac.IP(string(virtualIP.UID), r.APINetNamespace). + WithLabels(apinetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), virtualIP)). + WithSpec(apinetv1alpha1ac.IPSpec(). + WithType(apinetv1alpha1.IPTypePublic). + WithIPFamily(virtualIP.Spec.IPFamily), + ) + + apiNetIP, err := r.APINetInterface.CoreV1alpha1(). + IPs(r.APINetNamespace). + Apply(ctx, apiNetIPApplyCfg, metav1.ApplyOptions{FieldManager: string(fieldOwner), Force: true}) + if err != nil { + return netip.Addr{}, fmt.Errorf("error applying apinet IP: %w", err) } - log.V(1).Info("Applied apinet public ip") - if !apiNetPublicIP.IsAllocated() { - return netip.Addr{}, nil - } - ip := apiNetPublicIP.Spec.IP + log.V(1).Info("Applied APINet ip") + ip := apiNetIP.Spec.IP return ip.Addr, nil } func (r *VirtualIPReconciler) patchStatusAllocated(ctx context.Context, virtualIP *networkingv1alpha1.VirtualIP, addr netip.Addr) error { base := virtualIP.DeepCopy() virtualIP.Status.IP = &commonv1alpha1.IP{Addr: addr} - if err := r.Status().Patch(ctx, virtualIP, client.MergeFrom(base)); err != nil { + if err := r.Status().Patch(ctx, virtualIP, client.StrategicMergeFrom(base)); err != nil { return fmt.Errorf("error patching virtual ip status: %w", err) } return nil @@ -223,7 +202,7 @@ func (r *VirtualIPReconciler) patchStatusUnallocated(ctx context.Context, virtua return nil } -func (r *VirtualIPReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster cluster.Cluster) error { +func (r *VirtualIPReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCache cache.Cache) error { log := ctrl.Log.WithName("virtualip").WithName("setup") return ctrl.NewControllerManagedBy(mgr). @@ -235,29 +214,8 @@ func (r *VirtualIPReconciler) SetupWithManager(mgr ctrl.Manager, apiNetCluster c ), ). WatchesRawSource( - source.Kind(apiNetCluster.GetCache(), &onmetalapinetv1alpha1.PublicIP{}), - handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { - apiNetPublicIP := obj.(*onmetalapinetv1alpha1.PublicIP) - - if apiNetPublicIP.Namespace != r.APINetNamespace { - return nil - } - - namespace, ok := apiNetPublicIP.Labels[apinetletv1alpha1.VirtualIPNamespaceLabel] - if !ok { - return nil - } - - name, ok := apiNetPublicIP.Labels[apinetletv1alpha1.VirtualIPNameLabel] - if !ok { - return nil - } - - return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: namespace, Name: name}}} - }), - builder.WithPredicates( - getApiNetPublicIPAllocationChangedPredicate(), - ), + source.Kind(apiNetCache, &apinetv1alpha1.IP{}), + handler.EnqueueRequestForSource(r.Scheme(), mgr.GetRESTMapper(), &networkingv1alpha1.VirtualIP{}), ). Complete(r) } diff --git a/apinetlet/controllers/virtualip_controller_test.go b/apinetlet/controllers/virtualip_controller_test.go index 01d9dd3f..8879b535 100644 --- a/apinetlet/controllers/virtualip_controller_test.go +++ b/apinetlet/controllers/virtualip_controller_test.go @@ -15,13 +15,15 @@ package controllers import ( - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1" + apinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apinetletclient "github.com/onmetal/onmetal-api-net/apinetlet/client" + . "github.com/onmetal/onmetal-api-net/utils/testing" commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,10 +32,11 @@ import ( ) var _ = Describe("VirtualIPController", func() { - ctx := SetupContext() - ns := SetupTest(ctx) + ns := SetupNamespace(&k8sClient) + apiNetNs := SetupNamespace(&k8sClient) + SetupTest(apiNetNs) - It("should allocate a public ip", func() { + It("should allocate a virtual ip", func(ctx SpecContext) { By("creating a virtual ip") virtualIP := &networkingv1alpha1.VirtualIP{ ObjectMeta: metav1.ObjectMeta{ @@ -47,43 +50,23 @@ var _ = Describe("VirtualIPController", func() { } Expect(k8sClient.Create(ctx, virtualIP)).To(Succeed()) - By("waiting for the corresponding public ip to be created") - publicIP := &onmetalapinetv1alpha1.PublicIP{ + By("waiting for the corresponding ip to be created") + ip := &apinetv1alpha1.IP{ ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, + Namespace: apiNetNs.Name, Name: string(virtualIP.UID), }, } - Eventually(Get(publicIP)).Should(Succeed()) - - By("inspecting the created public ip") - Expect(publicIP.Labels).To(Equal(map[string]string{ - apinetletv1alpha1.VirtualIPNamespaceLabel: virtualIP.Namespace, - apinetletv1alpha1.VirtualIPNameLabel: virtualIP.Name, - apinetletv1alpha1.VirtualIPUIDLabel: string(virtualIP.UID), - })) - Expect(publicIP.Spec).To(Equal(onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - })) - - By("asserting the virtual ip does not get an ip address") - Consistently(Object(virtualIP)).Should(HaveField("Status.IP", BeNil())) - - By("patching the public ip spec ips") - basePublicIP := publicIP.DeepCopy() - publicIP.Spec.IP = onmetalapinetv1alpha1.MustParseNewIP("10.0.0.1") - Expect(k8sClient.Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) - - By("patching the public ip status to allocated") - basePublicIP = publicIP.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Status: corev1.ConditionTrue, - }) - Expect(k8sClient.Status().Patch(ctx, publicIP, client.MergeFrom(basePublicIP))).To(Succeed()) + Eventually(Object(ip)).Should(SatisfyAll( + HaveField("Labels", HaveKeysWithValues(apinetletclient.SourceLabels(k8sClient.Scheme(), k8sClient.RESTMapper(), virtualIP))), + HaveField("Spec", MatchFields(IgnoreExtras, Fields{ + "Type": Equal(apinetv1alpha1.IPTypePublic), + "IPFamily": Equal(corev1.IPv4Protocol), + })), + )) By("waiting for the virtual ip to reflect the allocated ip") - Eventually(Object(virtualIP)).Should(HaveField("Status.IP", Equal(commonv1alpha1.MustParseNewIP("10.0.0.1")))) + Eventually(Object(virtualIP)).Should(HaveField("Status.IP", &commonv1alpha1.IP{Addr: ip.Spec.IP.Addr})) By("deleting the virtual ip") Expect(k8sClient.Delete(ctx, virtualIP)).To(Succeed()) @@ -91,29 +74,8 @@ var _ = Describe("VirtualIPController", func() { By("waiting for it to be gone") Eventually(Get(virtualIP)).Should(Satisfy(apierrors.IsNotFound)) - By("asserting the corresponding public ip is gone as well") - Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(publicIP), publicIP)).To(Satisfy(apierrors.IsNotFound)) - }) - - It("should clean up dangling public ips", func() { - By("creating a public ip") - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "public-ip-", - Labels: map[string]string{ - apinetletv1alpha1.VirtualIPNamespaceLabel: ns.Name, - apinetletv1alpha1.VirtualIPNameLabel: "some-name", - apinetletv1alpha1.VirtualIPUIDLabel: "some-uid", - }, - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - - By("waiting for the public ip to be gone") - Eventually(Get(publicIP)).Should(Satisfy(apierrors.IsNotFound)) + By("asserting the corresponding ip is gone as well") + ipKey := client.ObjectKeyFromObject(ip) + Expect(k8sClient.Get(ctx, ipKey, ip)).To(Satisfy(apierrors.IsNotFound)) }) }) diff --git a/apinetlet/handler/sourceaware.go b/apinetlet/handler/sourceaware.go new file mode 100644 index 00000000..d99aa2d2 --- /dev/null +++ b/apinetlet/handler/sourceaware.go @@ -0,0 +1,26 @@ +// Copyright 2023 OnMetal 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 handler + +import ( + utilapi "github.com/onmetal/onmetal-api-net/utils/api" + utilhandler "github.com/onmetal/onmetal-api-net/utils/handler" +) + +var ( + SourceAwareSystem = utilhandler.NewSourceAwareSystem(utilapi.PrefixSourceAwareSystem("apinetlet.api.onmetal.de/")) + + EnqueueRequestForSource = SourceAwareSystem.EnqueueRequestForSource +) diff --git a/apinetlet/provider/provider.go b/apinetlet/provider/provider.go new file mode 100644 index 00000000..536358cd --- /dev/null +++ b/apinetlet/provider/provider.go @@ -0,0 +1,97 @@ +// Copyright 2023 OnMetal 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 provider + +import ( + "fmt" + "strings" + + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/types" +) + +const ( + apiNetPrefix = "onmetal-api-net://" +) + +// ParseNetworkInterfaceID parses network interface provider IDs. +// The format of a network interface provider id is as follows: +// onmetal-api-net:///// +func ParseNetworkInterfaceID(id string) (namespace, name, node string, uid types.UID, err error) { + parts := strings.SplitN(strings.TrimPrefix(id, apiNetPrefix), "/", 5) + if len(parts) != 4 { + return "", "", "", "", fmt.Errorf("invalid provider id %q", id) + } + + namespace = parts[0] + name = parts[1] + node = parts[2] + uid = types.UID(parts[3]) + if allErrs := validation.NameIsDNSLabel(node, false); len(allErrs) != 0 { + return "", "", "", "", fmt.Errorf("node is not a dns label: %v", allErrs) + } + + return namespace, name, node, uid, nil +} + +// GetNetworkInterfaceID creates a network interface provider ID. +// The format of a network interface provider id is as follows: +// onmetal-api-net:///// +func GetNetworkInterfaceID(namespace, name, node string, uid types.UID) string { + var sb strings.Builder + sb.Grow(len(apiNetPrefix) + len(node) + 1 + len(name) + 1 + len(uid)) + sb.WriteString(apiNetPrefix) + sb.WriteString(namespace) + sb.WriteRune('/') + sb.WriteString(name) + sb.WriteRune('/') + sb.WriteString(node) + sb.WriteRune('/') + sb.WriteString(string(uid)) + return sb.String() +} + +// ParseNetworkID parses network provider IDs into the apinet network name. +// The format of a network provider ID is as follows: +// onmetal-api-net://// +func ParseNetworkID(s string) (namespace, name, id string, uid types.UID, err error) { + parts := strings.SplitN(strings.TrimPrefix(id, apiNetPrefix), "/", 5) + if len(parts) != 4 { + return "", "", "", "", fmt.Errorf("invalid provider id %q", id) + } + + namespace = parts[0] + name = parts[1] + id = parts[2] + uid = types.UID(parts[3]) + return namespace, name, id, uid, nil +} + +// GetNetworkID creates a network ID from the given id, name and UID. +// The format of a network provider ID is as follows: +// onmetal-api-net:///// +func GetNetworkID(namespace, name, id string, uid types.UID) string { + var sb strings.Builder + sb.Grow(len(apiNetPrefix) + len(namespace) + 1 + len(id) + 1 + len(name) + 1 + len(uid)) + sb.WriteString(apiNetPrefix) + sb.WriteString(namespace) + sb.WriteRune('/') + sb.WriteString(id) + sb.WriteRune('/') + sb.WriteString(name) + sb.WriteRune('/') + sb.WriteString(string(uid)) + return sb.String() +} diff --git a/apinetlet/provider/provider_suite_test.go b/apinetlet/provider/provider_suite_test.go new file mode 100644 index 00000000..c32dcfbb --- /dev/null +++ b/apinetlet/provider/provider_suite_test.go @@ -0,0 +1,27 @@ +// Copyright 2023 OnMetal 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 provider_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestProvider(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Provider Suite") +} diff --git a/apinetlet/provider/provider_test.go b/apinetlet/provider/provider_test.go new file mode 100644 index 00000000..6dba0b80 --- /dev/null +++ b/apinetlet/provider/provider_test.go @@ -0,0 +1,52 @@ +// Copyright 2023 OnMetal 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 provider_test + +import ( + . "github.com/onmetal/onmetal-api-net/apinetlet/provider" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/types" +) + +var _ = Describe("Provider", func() { + const ( + namespace = "namespace" + node = "node" + name = "name" + uid = types.UID("2c24a85c-b55d-44b8-bf6e-1872ecfef5db") + ) + + Context("NetworkInterfaceID", func() { + const providerID = string("onmetal-api-net://" + namespace + "/" + name + "/" + node + "/" + uid) + + Describe("GetNetworkInterfaceID", func() { + It("should produce a correct network interface ID", func() { + Expect(GetNetworkInterfaceID(namespace, name, node, uid)).To(Equal(providerID)) + }) + }) + + Describe("ParseNetworkInterfaceID", func() { + It("should parse the given network interface ID", func() { + actualNs, actualName, actualNode, actualUID, err := ParseNetworkInterfaceID(providerID) + Expect(err).NotTo(HaveOccurred()) + Expect(actualNs).To(Equal(namespace)) + Expect(actualName).To(Equal(name)) + Expect(actualNode).To(Equal(node)) + Expect(actualUID).To(Equal(uid)) + }) + }) + }) +}) diff --git a/client-go/applyconfigurations/core/v1alpha1/affinity.go b/client-go/applyconfigurations/core/v1alpha1/affinity.go new file mode 100644 index 00000000..e2276c56 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/affinity.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AffinityApplyConfiguration represents an declarative configuration of the Affinity type for use +// with apply. +type AffinityApplyConfiguration struct { + NodeAffinity *NodeAffinityApplyConfiguration `json:"nodeAffinity,omitempty"` + InstanceAntiAffinity *InstanceAntiAffinityApplyConfiguration `json:"instanceAntiAffinity,omitempty"` +} + +// AffinityApplyConfiguration constructs an declarative configuration of the Affinity type for use with +// apply. +func Affinity() *AffinityApplyConfiguration { + return &AffinityApplyConfiguration{} +} + +// WithNodeAffinity sets the NodeAffinity field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeAffinity field is set to the value of the last call. +func (b *AffinityApplyConfiguration) WithNodeAffinity(value *NodeAffinityApplyConfiguration) *AffinityApplyConfiguration { + b.NodeAffinity = value + return b +} + +// WithInstanceAntiAffinity sets the InstanceAntiAffinity field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InstanceAntiAffinity field is set to the value of the last call. +func (b *AffinityApplyConfiguration) WithInstanceAntiAffinity(value *InstanceAntiAffinityApplyConfiguration) *AffinityApplyConfiguration { + b.InstanceAntiAffinity = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/daemonset.go b/client-go/applyconfigurations/core/v1alpha1/daemonset.go new file mode 100644 index 00000000..4dc81dc5 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/daemonset.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// DaemonSetApplyConfiguration represents an declarative configuration of the DaemonSet type for use +// with apply. +type DaemonSetApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *DaemonSetSpecApplyConfiguration `json:"spec,omitempty"` + Status *DaemonSetStatusApplyConfiguration `json:"status,omitempty"` +} + +// DaemonSet constructs an declarative configuration of the DaemonSet type for use with +// apply. +func DaemonSet(name, namespace string) *DaemonSetApplyConfiguration { + b := &DaemonSetApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("DaemonSet") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractDaemonSet extracts the applied configuration owned by fieldManager from +// daemonSet. If no managedFields are found in daemonSet for fieldManager, a +// DaemonSetApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// daemonSet must be a unmodified DaemonSet API object that was retrieved from the Kubernetes API. +// ExtractDaemonSet provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractDaemonSet(daemonSet *corev1alpha1.DaemonSet, fieldManager string) (*DaemonSetApplyConfiguration, error) { + return extractDaemonSet(daemonSet, fieldManager, "") +} + +// ExtractDaemonSetStatus is the same as ExtractDaemonSet except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractDaemonSetStatus(daemonSet *corev1alpha1.DaemonSet, fieldManager string) (*DaemonSetApplyConfiguration, error) { + return extractDaemonSet(daemonSet, fieldManager, "status") +} + +func extractDaemonSet(daemonSet *corev1alpha1.DaemonSet, fieldManager string, subresource string) (*DaemonSetApplyConfiguration, error) { + b := &DaemonSetApplyConfiguration{} + err := managedfields.ExtractInto(daemonSet, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSet"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(daemonSet.Name) + b.WithNamespace(daemonSet.Namespace) + + b.WithKind("DaemonSet") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithKind(value string) *DaemonSetApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithAPIVersion(value string) *DaemonSetApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithName(value string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithGenerateName(value string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithNamespace(value string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithUID(value types.UID) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithResourceVersion(value string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithGeneration(value int64) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithCreationTimestamp(value metav1.Time) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *DaemonSetApplyConfiguration) WithLabels(entries map[string]string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *DaemonSetApplyConfiguration) WithAnnotations(entries map[string]string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *DaemonSetApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *DaemonSetApplyConfiguration) WithFinalizers(values ...string) *DaemonSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *DaemonSetApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithSpec(value *DaemonSetSpecApplyConfiguration) *DaemonSetApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *DaemonSetApplyConfiguration) WithStatus(value *DaemonSetStatusApplyConfiguration) *DaemonSetApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/daemonsetspec.go b/client-go/applyconfigurations/core/v1alpha1/daemonsetspec.go new file mode 100644 index 00000000..6ab2dde6 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/daemonsetspec.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" +) + +// DaemonSetSpecApplyConfiguration represents an declarative configuration of the DaemonSetSpec type for use +// with apply. +type DaemonSetSpecApplyConfiguration struct { + Selector *v1.LabelSelectorApplyConfiguration `json:"nodeSelector,omitempty"` + Template *InstanceTemplateApplyConfiguration `json:"template,omitempty"` +} + +// DaemonSetSpecApplyConfiguration constructs an declarative configuration of the DaemonSetSpec type for use with +// apply. +func DaemonSetSpec() *DaemonSetSpecApplyConfiguration { + return &DaemonSetSpecApplyConfiguration{} +} + +// WithSelector sets the Selector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Selector field is set to the value of the last call. +func (b *DaemonSetSpecApplyConfiguration) WithSelector(value *v1.LabelSelectorApplyConfiguration) *DaemonSetSpecApplyConfiguration { + b.Selector = value + return b +} + +// WithTemplate sets the Template field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Template field is set to the value of the last call. +func (b *DaemonSetSpecApplyConfiguration) WithTemplate(value *InstanceTemplateApplyConfiguration) *DaemonSetSpecApplyConfiguration { + b.Template = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/daemonsetstatus.go b/client-go/applyconfigurations/core/v1alpha1/daemonsetstatus.go new file mode 100644 index 00000000..eaab660d --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/daemonsetstatus.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// DaemonSetStatusApplyConfiguration represents an declarative configuration of the DaemonSetStatus type for use +// with apply. +type DaemonSetStatusApplyConfiguration struct { + CollisionCount *int32 `json:"collisionCount,omitempty"` +} + +// DaemonSetStatusApplyConfiguration constructs an declarative configuration of the DaemonSetStatus type for use with +// apply. +func DaemonSetStatus() *DaemonSetStatusApplyConfiguration { + return &DaemonSetStatusApplyConfiguration{} +} + +// WithCollisionCount sets the CollisionCount field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CollisionCount field is set to the value of the last call. +func (b *DaemonSetStatusApplyConfiguration) WithCollisionCount(value int32) *DaemonSetStatusApplyConfiguration { + b.CollisionCount = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instance.go b/client-go/applyconfigurations/core/v1alpha1/instance.go new file mode 100644 index 00000000..4f536a62 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instance.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// InstanceApplyConfiguration represents an declarative configuration of the Instance type for use +// with apply. +type InstanceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *InstanceSpecApplyConfiguration `json:"spec,omitempty"` + Status *InstanceStatusApplyConfiguration `json:"status,omitempty"` +} + +// Instance constructs an declarative configuration of the Instance type for use with +// apply. +func Instance(name, namespace string) *InstanceApplyConfiguration { + b := &InstanceApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Instance") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractInstance extracts the applied configuration owned by fieldManager from +// instance. If no managedFields are found in instance for fieldManager, a +// InstanceApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// instance must be a unmodified Instance API object that was retrieved from the Kubernetes API. +// ExtractInstance provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractInstance(instance *corev1alpha1.Instance, fieldManager string) (*InstanceApplyConfiguration, error) { + return extractInstance(instance, fieldManager, "") +} + +// ExtractInstanceStatus is the same as ExtractInstance except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractInstanceStatus(instance *corev1alpha1.Instance, fieldManager string) (*InstanceApplyConfiguration, error) { + return extractInstance(instance, fieldManager, "status") +} + +func extractInstance(instance *corev1alpha1.Instance, fieldManager string, subresource string) (*InstanceApplyConfiguration, error) { + b := &InstanceApplyConfiguration{} + err := managedfields.ExtractInto(instance, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Instance"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(instance.Name) + b.WithNamespace(instance.Namespace) + + b.WithKind("Instance") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithKind(value string) *InstanceApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithAPIVersion(value string) *InstanceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithName(value string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithGenerateName(value string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithNamespace(value string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithUID(value types.UID) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithResourceVersion(value string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithGeneration(value int64) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *InstanceApplyConfiguration) WithLabels(entries map[string]string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *InstanceApplyConfiguration) WithAnnotations(entries map[string]string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *InstanceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *InstanceApplyConfiguration) WithFinalizers(values ...string) *InstanceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *InstanceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithSpec(value *InstanceSpecApplyConfiguration) *InstanceApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *InstanceApplyConfiguration) WithStatus(value *InstanceStatusApplyConfiguration) *InstanceApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instanceaffinityterm.go b/client-go/applyconfigurations/core/v1alpha1/instanceaffinityterm.go new file mode 100644 index 00000000..87ea36dc --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instanceaffinityterm.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" +) + +// InstanceAffinityTermApplyConfiguration represents an declarative configuration of the InstanceAffinityTerm type for use +// with apply. +type InstanceAffinityTermApplyConfiguration struct { + LabelSelector *v1.LabelSelectorApplyConfiguration `json:"labelSelector,omitempty"` + TopologyKey *string `json:"topologyKey,omitempty"` +} + +// InstanceAffinityTermApplyConfiguration constructs an declarative configuration of the InstanceAffinityTerm type for use with +// apply. +func InstanceAffinityTerm() *InstanceAffinityTermApplyConfiguration { + return &InstanceAffinityTermApplyConfiguration{} +} + +// WithLabelSelector sets the LabelSelector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LabelSelector field is set to the value of the last call. +func (b *InstanceAffinityTermApplyConfiguration) WithLabelSelector(value *v1.LabelSelectorApplyConfiguration) *InstanceAffinityTermApplyConfiguration { + b.LabelSelector = value + return b +} + +// WithTopologyKey sets the TopologyKey field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TopologyKey field is set to the value of the last call. +func (b *InstanceAffinityTermApplyConfiguration) WithTopologyKey(value string) *InstanceAffinityTermApplyConfiguration { + b.TopologyKey = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instanceantiaffinity.go b/client-go/applyconfigurations/core/v1alpha1/instanceantiaffinity.go new file mode 100644 index 00000000..496841a3 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instanceantiaffinity.go @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// InstanceAntiAffinityApplyConfiguration represents an declarative configuration of the InstanceAntiAffinity type for use +// with apply. +type InstanceAntiAffinityApplyConfiguration struct { + RequiredDuringSchedulingIgnoredDuringExecution []InstanceAffinityTermApplyConfiguration `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"` +} + +// InstanceAntiAffinityApplyConfiguration constructs an declarative configuration of the InstanceAntiAffinity type for use with +// apply. +func InstanceAntiAffinity() *InstanceAntiAffinityApplyConfiguration { + return &InstanceAntiAffinityApplyConfiguration{} +} + +// WithRequiredDuringSchedulingIgnoredDuringExecution adds the given value to the RequiredDuringSchedulingIgnoredDuringExecution field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RequiredDuringSchedulingIgnoredDuringExecution field. +func (b *InstanceAntiAffinityApplyConfiguration) WithRequiredDuringSchedulingIgnoredDuringExecution(values ...*InstanceAffinityTermApplyConfiguration) *InstanceAntiAffinityApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithRequiredDuringSchedulingIgnoredDuringExecution") + } + b.RequiredDuringSchedulingIgnoredDuringExecution = append(b.RequiredDuringSchedulingIgnoredDuringExecution, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instancespec.go b/client-go/applyconfigurations/core/v1alpha1/instancespec.go new file mode 100644 index 00000000..27439bb7 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instancespec.go @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + v1 "k8s.io/api/core/v1" +) + +// InstanceSpecApplyConfiguration represents an declarative configuration of the InstanceSpec type for use +// with apply. +type InstanceSpecApplyConfiguration struct { + Type *v1alpha1.InstanceType `json:"type,omitempty"` + LoadBalancerType *v1alpha1.LoadBalancerType `json:"loadBalancerType,omitempty"` + NetworkRef *v1.LocalObjectReference `json:"networkRef,omitempty"` + IPs []net.IP `json:"ips,omitempty"` + LoadBalancerPorts []LoadBalancerPortApplyConfiguration `json:"loadBalancerPorts,omitempty"` + Affinity *AffinityApplyConfiguration `json:"affinity,omitempty"` + TopologySpreadConstraints []TopologySpreadConstraintApplyConfiguration `json:"topologySpreadConstraints,omitempty"` + NodeRef *v1.LocalObjectReference `json:"nodeRef,omitempty"` +} + +// InstanceSpecApplyConfiguration constructs an declarative configuration of the InstanceSpec type for use with +// apply. +func InstanceSpec() *InstanceSpecApplyConfiguration { + return &InstanceSpecApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *InstanceSpecApplyConfiguration) WithType(value v1alpha1.InstanceType) *InstanceSpecApplyConfiguration { + b.Type = &value + return b +} + +// WithLoadBalancerType sets the LoadBalancerType field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LoadBalancerType field is set to the value of the last call. +func (b *InstanceSpecApplyConfiguration) WithLoadBalancerType(value v1alpha1.LoadBalancerType) *InstanceSpecApplyConfiguration { + b.LoadBalancerType = &value + return b +} + +// WithNetworkRef sets the NetworkRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NetworkRef field is set to the value of the last call. +func (b *InstanceSpecApplyConfiguration) WithNetworkRef(value v1.LocalObjectReference) *InstanceSpecApplyConfiguration { + b.NetworkRef = &value + return b +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *InstanceSpecApplyConfiguration) WithIPs(values ...net.IP) *InstanceSpecApplyConfiguration { + for i := range values { + b.IPs = append(b.IPs, values[i]) + } + return b +} + +// WithLoadBalancerPorts adds the given value to the LoadBalancerPorts field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the LoadBalancerPorts field. +func (b *InstanceSpecApplyConfiguration) WithLoadBalancerPorts(values ...*LoadBalancerPortApplyConfiguration) *InstanceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithLoadBalancerPorts") + } + b.LoadBalancerPorts = append(b.LoadBalancerPorts, *values[i]) + } + return b +} + +// WithAffinity sets the Affinity field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Affinity field is set to the value of the last call. +func (b *InstanceSpecApplyConfiguration) WithAffinity(value *AffinityApplyConfiguration) *InstanceSpecApplyConfiguration { + b.Affinity = value + return b +} + +// WithTopologySpreadConstraints adds the given value to the TopologySpreadConstraints field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the TopologySpreadConstraints field. +func (b *InstanceSpecApplyConfiguration) WithTopologySpreadConstraints(values ...*TopologySpreadConstraintApplyConfiguration) *InstanceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithTopologySpreadConstraints") + } + b.TopologySpreadConstraints = append(b.TopologySpreadConstraints, *values[i]) + } + return b +} + +// WithNodeRef sets the NodeRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeRef field is set to the value of the last call. +func (b *InstanceSpecApplyConfiguration) WithNodeRef(value v1.LocalObjectReference) *InstanceSpecApplyConfiguration { + b.NodeRef = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instancestatus.go b/client-go/applyconfigurations/core/v1alpha1/instancestatus.go new file mode 100644 index 00000000..07256173 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instancestatus.go @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// InstanceStatusApplyConfiguration represents an declarative configuration of the InstanceStatus type for use +// with apply. +type InstanceStatusApplyConfiguration struct { + IPs []net.IP `json:"ips,omitempty"` + CollisionCount *int32 `json:"collisionCount,omitempty"` +} + +// InstanceStatusApplyConfiguration constructs an declarative configuration of the InstanceStatus type for use with +// apply. +func InstanceStatus() *InstanceStatusApplyConfiguration { + return &InstanceStatusApplyConfiguration{} +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *InstanceStatusApplyConfiguration) WithIPs(values ...net.IP) *InstanceStatusApplyConfiguration { + for i := range values { + b.IPs = append(b.IPs, values[i]) + } + return b +} + +// WithCollisionCount sets the CollisionCount field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CollisionCount field is set to the value of the last call. +func (b *InstanceStatusApplyConfiguration) WithCollisionCount(value int32) *InstanceStatusApplyConfiguration { + b.CollisionCount = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/instancetemplate.go b/client-go/applyconfigurations/core/v1alpha1/instancetemplate.go new file mode 100644 index 00000000..49d26dc7 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/instancetemplate.go @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" +) + +// InstanceTemplateApplyConfiguration represents an declarative configuration of the InstanceTemplate type for use +// with apply. +type InstanceTemplateApplyConfiguration struct { + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *InstanceSpecApplyConfiguration `json:"spec,omitempty"` +} + +// InstanceTemplateApplyConfiguration constructs an declarative configuration of the InstanceTemplate type for use with +// apply. +func InstanceTemplate() *InstanceTemplateApplyConfiguration { + return &InstanceTemplateApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithName(value string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithGenerateName(value string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithNamespace(value string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithUID(value types.UID) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithResourceVersion(value string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithGeneration(value int64) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithCreationTimestamp(value metav1.Time) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *InstanceTemplateApplyConfiguration) WithLabels(entries map[string]string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *InstanceTemplateApplyConfiguration) WithAnnotations(entries map[string]string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *InstanceTemplateApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *InstanceTemplateApplyConfiguration) WithFinalizers(values ...string) *InstanceTemplateApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *InstanceTemplateApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *InstanceTemplateApplyConfiguration) WithSpec(value *InstanceSpecApplyConfiguration) *InstanceTemplateApplyConfiguration { + b.Spec = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ip.go b/client-go/applyconfigurations/core/v1alpha1/ip.go new file mode 100644 index 00000000..f92fc21b --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ip.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// IPApplyConfiguration represents an declarative configuration of the IP type for use +// with apply. +type IPApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *IPSpecApplyConfiguration `json:"spec,omitempty"` + Status *corev1alpha1.IPStatus `json:"status,omitempty"` +} + +// IP constructs an declarative configuration of the IP type for use with +// apply. +func IP(name, namespace string) *IPApplyConfiguration { + b := &IPApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("IP") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractIP extracts the applied configuration owned by fieldManager from +// iP. If no managedFields are found in iP for fieldManager, a +// IPApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// iP must be a unmodified IP API object that was retrieved from the Kubernetes API. +// ExtractIP provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractIP(iP *corev1alpha1.IP, fieldManager string) (*IPApplyConfiguration, error) { + return extractIP(iP, fieldManager, "") +} + +// ExtractIPStatus is the same as ExtractIP except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractIPStatus(iP *corev1alpha1.IP, fieldManager string) (*IPApplyConfiguration, error) { + return extractIP(iP, fieldManager, "status") +} + +func extractIP(iP *corev1alpha1.IP, fieldManager string, subresource string) (*IPApplyConfiguration, error) { + b := &IPApplyConfiguration{} + err := managedfields.ExtractInto(iP, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IP"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(iP.Name) + b.WithNamespace(iP.Namespace) + + b.WithKind("IP") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *IPApplyConfiguration) WithKind(value string) *IPApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *IPApplyConfiguration) WithAPIVersion(value string) *IPApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *IPApplyConfiguration) WithName(value string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *IPApplyConfiguration) WithGenerateName(value string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *IPApplyConfiguration) WithNamespace(value string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *IPApplyConfiguration) WithUID(value types.UID) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *IPApplyConfiguration) WithResourceVersion(value string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *IPApplyConfiguration) WithGeneration(value int64) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *IPApplyConfiguration) WithCreationTimestamp(value metav1.Time) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *IPApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *IPApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *IPApplyConfiguration) WithLabels(entries map[string]string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *IPApplyConfiguration) WithAnnotations(entries map[string]string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *IPApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *IPApplyConfiguration) WithFinalizers(values ...string) *IPApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *IPApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *IPApplyConfiguration) WithSpec(value *IPSpecApplyConfiguration) *IPApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *IPApplyConfiguration) WithStatus(value corev1alpha1.IPStatus) *IPApplyConfiguration { + b.Status = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ipaddress.go b/client-go/applyconfigurations/core/v1alpha1/ipaddress.go new file mode 100644 index 00000000..30103348 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ipaddress.go @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// IPAddressApplyConfiguration represents an declarative configuration of the IPAddress type for use +// with apply. +type IPAddressApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *IPAddressSpecApplyConfiguration `json:"spec,omitempty"` +} + +// IPAddress constructs an declarative configuration of the IPAddress type for use with +// apply. +func IPAddress(name string) *IPAddressApplyConfiguration { + b := &IPAddressApplyConfiguration{} + b.WithName(name) + b.WithKind("IPAddress") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractIPAddress extracts the applied configuration owned by fieldManager from +// iPAddress. If no managedFields are found in iPAddress for fieldManager, a +// IPAddressApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// iPAddress must be a unmodified IPAddress API object that was retrieved from the Kubernetes API. +// ExtractIPAddress provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractIPAddress(iPAddress *corev1alpha1.IPAddress, fieldManager string) (*IPAddressApplyConfiguration, error) { + return extractIPAddress(iPAddress, fieldManager, "") +} + +// ExtractIPAddressStatus is the same as ExtractIPAddress except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractIPAddressStatus(iPAddress *corev1alpha1.IPAddress, fieldManager string) (*IPAddressApplyConfiguration, error) { + return extractIPAddress(iPAddress, fieldManager, "status") +} + +func extractIPAddress(iPAddress *corev1alpha1.IPAddress, fieldManager string, subresource string) (*IPAddressApplyConfiguration, error) { + b := &IPAddressApplyConfiguration{} + err := managedfields.ExtractInto(iPAddress, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddress"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(iPAddress.Name) + + b.WithKind("IPAddress") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithKind(value string) *IPAddressApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithAPIVersion(value string) *IPAddressApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithName(value string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithGenerateName(value string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithNamespace(value string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithUID(value types.UID) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithResourceVersion(value string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithGeneration(value int64) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithCreationTimestamp(value metav1.Time) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *IPAddressApplyConfiguration) WithLabels(entries map[string]string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *IPAddressApplyConfiguration) WithAnnotations(entries map[string]string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *IPAddressApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *IPAddressApplyConfiguration) WithFinalizers(values ...string) *IPAddressApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *IPAddressApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *IPAddressApplyConfiguration) WithSpec(value *IPAddressSpecApplyConfiguration) *IPAddressApplyConfiguration { + b.Spec = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ipaddressclaimref.go b/client-go/applyconfigurations/core/v1alpha1/ipaddressclaimref.go new file mode 100644 index 00000000..8f40cff7 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ipaddressclaimref.go @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + types "k8s.io/apimachinery/pkg/types" +) + +// IPAddressClaimRefApplyConfiguration represents an declarative configuration of the IPAddressClaimRef type for use +// with apply. +type IPAddressClaimRefApplyConfiguration struct { + Group *string `json:"group,omitempty"` + Resource *string `json:"resource,omitempty"` + Namespace *string `json:"namespace,omitempty"` + Name *string `json:"name,omitempty"` + UID *types.UID `json:"uid,omitempty"` +} + +// IPAddressClaimRefApplyConfiguration constructs an declarative configuration of the IPAddressClaimRef type for use with +// apply. +func IPAddressClaimRef() *IPAddressClaimRefApplyConfiguration { + return &IPAddressClaimRefApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *IPAddressClaimRefApplyConfiguration) WithGroup(value string) *IPAddressClaimRefApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *IPAddressClaimRefApplyConfiguration) WithResource(value string) *IPAddressClaimRefApplyConfiguration { + b.Resource = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *IPAddressClaimRefApplyConfiguration) WithNamespace(value string) *IPAddressClaimRefApplyConfiguration { + b.Namespace = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *IPAddressClaimRefApplyConfiguration) WithName(value string) *IPAddressClaimRefApplyConfiguration { + b.Name = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *IPAddressClaimRefApplyConfiguration) WithUID(value types.UID) *IPAddressClaimRefApplyConfiguration { + b.UID = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ipaddressspec.go b/client-go/applyconfigurations/core/v1alpha1/ipaddressspec.go new file mode 100644 index 00000000..b745f99d --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ipaddressspec.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// IPAddressSpecApplyConfiguration represents an declarative configuration of the IPAddressSpec type for use +// with apply. +type IPAddressSpecApplyConfiguration struct { + IP *net.IP `json:"ip,omitempty"` + ClaimRef *IPAddressClaimRefApplyConfiguration `json:"claimRef,omitempty"` +} + +// IPAddressSpecApplyConfiguration constructs an declarative configuration of the IPAddressSpec type for use with +// apply. +func IPAddressSpec() *IPAddressSpecApplyConfiguration { + return &IPAddressSpecApplyConfiguration{} +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *IPAddressSpecApplyConfiguration) WithIP(value net.IP) *IPAddressSpecApplyConfiguration { + b.IP = &value + return b +} + +// WithClaimRef sets the ClaimRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClaimRef field is set to the value of the last call. +func (b *IPAddressSpecApplyConfiguration) WithClaimRef(value *IPAddressClaimRefApplyConfiguration) *IPAddressSpecApplyConfiguration { + b.ClaimRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ipclaimref.go b/client-go/applyconfigurations/core/v1alpha1/ipclaimref.go new file mode 100644 index 00000000..c55b078d --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ipclaimref.go @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + types "k8s.io/apimachinery/pkg/types" +) + +// IPClaimRefApplyConfiguration represents an declarative configuration of the IPClaimRef type for use +// with apply. +type IPClaimRefApplyConfiguration struct { + Group *string `json:"group,omitempty"` + Resource *string `json:"resource,omitempty"` + Name *string `json:"name,omitempty"` + UID *types.UID `json:"uid,omitempty"` +} + +// IPClaimRefApplyConfiguration constructs an declarative configuration of the IPClaimRef type for use with +// apply. +func IPClaimRef() *IPClaimRefApplyConfiguration { + return &IPClaimRefApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *IPClaimRefApplyConfiguration) WithGroup(value string) *IPClaimRefApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *IPClaimRefApplyConfiguration) WithResource(value string) *IPClaimRefApplyConfiguration { + b.Resource = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *IPClaimRefApplyConfiguration) WithName(value string) *IPClaimRefApplyConfiguration { + b.Name = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *IPClaimRefApplyConfiguration) WithUID(value types.UID) *IPClaimRefApplyConfiguration { + b.UID = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/ipspec.go b/client-go/applyconfigurations/core/v1alpha1/ipspec.go new file mode 100644 index 00000000..a36fdd1e --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/ipspec.go @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + v1 "k8s.io/api/core/v1" +) + +// IPSpecApplyConfiguration represents an declarative configuration of the IPSpec type for use +// with apply. +type IPSpecApplyConfiguration struct { + Type *v1alpha1.IPType `json:"type,omitempty"` + IPFamily *v1.IPFamily `json:"ipFamily,omitempty"` + IP *net.IP `json:"ip,omitempty"` + ClaimRef *IPClaimRefApplyConfiguration `json:"claimRef,omitempty"` +} + +// IPSpecApplyConfiguration constructs an declarative configuration of the IPSpec type for use with +// apply. +func IPSpec() *IPSpecApplyConfiguration { + return &IPSpecApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *IPSpecApplyConfiguration) WithType(value v1alpha1.IPType) *IPSpecApplyConfiguration { + b.Type = &value + return b +} + +// WithIPFamily sets the IPFamily field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPFamily field is set to the value of the last call. +func (b *IPSpecApplyConfiguration) WithIPFamily(value v1.IPFamily) *IPSpecApplyConfiguration { + b.IPFamily = &value + return b +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *IPSpecApplyConfiguration) WithIP(value net.IP) *IPSpecApplyConfiguration { + b.IP = &value + return b +} + +// WithClaimRef sets the ClaimRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClaimRef field is set to the value of the last call. +func (b *IPSpecApplyConfiguration) WithClaimRef(value *IPClaimRefApplyConfiguration) *IPSpecApplyConfiguration { + b.ClaimRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancer.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancer.go new file mode 100644 index 00000000..fdd7bf30 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancer.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// LoadBalancerApplyConfiguration represents an declarative configuration of the LoadBalancer type for use +// with apply. +type LoadBalancerApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *LoadBalancerSpecApplyConfiguration `json:"spec,omitempty"` + Status *LoadBalancerStatusApplyConfiguration `json:"status,omitempty"` +} + +// LoadBalancer constructs an declarative configuration of the LoadBalancer type for use with +// apply. +func LoadBalancer(name, namespace string) *LoadBalancerApplyConfiguration { + b := &LoadBalancerApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("LoadBalancer") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractLoadBalancer extracts the applied configuration owned by fieldManager from +// loadBalancer. If no managedFields are found in loadBalancer for fieldManager, a +// LoadBalancerApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// loadBalancer must be a unmodified LoadBalancer API object that was retrieved from the Kubernetes API. +// ExtractLoadBalancer provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractLoadBalancer(loadBalancer *corev1alpha1.LoadBalancer, fieldManager string) (*LoadBalancerApplyConfiguration, error) { + return extractLoadBalancer(loadBalancer, fieldManager, "") +} + +// ExtractLoadBalancerStatus is the same as ExtractLoadBalancer except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractLoadBalancerStatus(loadBalancer *corev1alpha1.LoadBalancer, fieldManager string) (*LoadBalancerApplyConfiguration, error) { + return extractLoadBalancer(loadBalancer, fieldManager, "status") +} + +func extractLoadBalancer(loadBalancer *corev1alpha1.LoadBalancer, fieldManager string, subresource string) (*LoadBalancerApplyConfiguration, error) { + b := &LoadBalancerApplyConfiguration{} + err := managedfields.ExtractInto(loadBalancer, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancer"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(loadBalancer.Name) + b.WithNamespace(loadBalancer.Namespace) + + b.WithKind("LoadBalancer") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithKind(value string) *LoadBalancerApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithAPIVersion(value string) *LoadBalancerApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithName(value string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithGenerateName(value string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithNamespace(value string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithUID(value types.UID) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithResourceVersion(value string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithGeneration(value int64) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithCreationTimestamp(value metav1.Time) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *LoadBalancerApplyConfiguration) WithLabels(entries map[string]string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *LoadBalancerApplyConfiguration) WithAnnotations(entries map[string]string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *LoadBalancerApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *LoadBalancerApplyConfiguration) WithFinalizers(values ...string) *LoadBalancerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *LoadBalancerApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithSpec(value *LoadBalancerSpecApplyConfiguration) *LoadBalancerApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *LoadBalancerApplyConfiguration) WithStatus(value *LoadBalancerStatusApplyConfiguration) *LoadBalancerApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerdestination.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerdestination.go new file mode 100644 index 00000000..af64ce67 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerdestination.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// LoadBalancerDestinationApplyConfiguration represents an declarative configuration of the LoadBalancerDestination type for use +// with apply. +type LoadBalancerDestinationApplyConfiguration struct { + IP *net.IP `json:"ip,omitempty"` + TargetRef *LoadBalancerTargetRefApplyConfiguration `json:"targetRef,omitempty"` +} + +// LoadBalancerDestinationApplyConfiguration constructs an declarative configuration of the LoadBalancerDestination type for use with +// apply. +func LoadBalancerDestination() *LoadBalancerDestinationApplyConfiguration { + return &LoadBalancerDestinationApplyConfiguration{} +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *LoadBalancerDestinationApplyConfiguration) WithIP(value net.IP) *LoadBalancerDestinationApplyConfiguration { + b.IP = &value + return b +} + +// WithTargetRef sets the TargetRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TargetRef field is set to the value of the last call. +func (b *LoadBalancerDestinationApplyConfiguration) WithTargetRef(value *LoadBalancerTargetRefApplyConfiguration) *LoadBalancerDestinationApplyConfiguration { + b.TargetRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerip.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerip.go new file mode 100644 index 00000000..0e06dab1 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerip.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + v1 "k8s.io/api/core/v1" +) + +// LoadBalancerIPApplyConfiguration represents an declarative configuration of the LoadBalancerIP type for use +// with apply. +type LoadBalancerIPApplyConfiguration struct { + Name *string `json:"name,omitempty"` + IPFamily *v1.IPFamily `json:"ipFamily,omitempty"` + IP *net.IP `json:"ip,omitempty"` +} + +// LoadBalancerIPApplyConfiguration constructs an declarative configuration of the LoadBalancerIP type for use with +// apply. +func LoadBalancerIP() *LoadBalancerIPApplyConfiguration { + return &LoadBalancerIPApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LoadBalancerIPApplyConfiguration) WithName(value string) *LoadBalancerIPApplyConfiguration { + b.Name = &value + return b +} + +// WithIPFamily sets the IPFamily field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPFamily field is set to the value of the last call. +func (b *LoadBalancerIPApplyConfiguration) WithIPFamily(value v1.IPFamily) *LoadBalancerIPApplyConfiguration { + b.IPFamily = &value + return b +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *LoadBalancerIPApplyConfiguration) WithIP(value net.IP) *LoadBalancerIPApplyConfiguration { + b.IP = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerport.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerport.go new file mode 100644 index 00000000..d0b4922d --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerport.go @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// LoadBalancerPortApplyConfiguration represents an declarative configuration of the LoadBalancerPort type for use +// with apply. +type LoadBalancerPortApplyConfiguration struct { + Protocol *v1.Protocol `json:"protocol,omitempty"` + Port *int32 `json:"port,omitempty"` + EndPort *int32 `json:"endPort,omitempty"` +} + +// LoadBalancerPortApplyConfiguration constructs an declarative configuration of the LoadBalancerPort type for use with +// apply. +func LoadBalancerPort() *LoadBalancerPortApplyConfiguration { + return &LoadBalancerPortApplyConfiguration{} +} + +// WithProtocol sets the Protocol field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Protocol field is set to the value of the last call. +func (b *LoadBalancerPortApplyConfiguration) WithProtocol(value v1.Protocol) *LoadBalancerPortApplyConfiguration { + b.Protocol = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *LoadBalancerPortApplyConfiguration) WithPort(value int32) *LoadBalancerPortApplyConfiguration { + b.Port = &value + return b +} + +// WithEndPort sets the EndPort field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the EndPort field is set to the value of the last call. +func (b *LoadBalancerPortApplyConfiguration) WithEndPort(value int32) *LoadBalancerPortApplyConfiguration { + b.EndPort = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerrouting.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerrouting.go new file mode 100644 index 00000000..60871875 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerrouting.go @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// LoadBalancerRoutingApplyConfiguration represents an declarative configuration of the LoadBalancerRouting type for use +// with apply. +type LoadBalancerRoutingApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + IPs []net.IP `json:"ips,omitempty"` + Destinations []LoadBalancerDestinationApplyConfiguration `json:"destinations,omitempty"` +} + +// LoadBalancerRouting constructs an declarative configuration of the LoadBalancerRouting type for use with +// apply. +func LoadBalancerRouting(name, namespace string) *LoadBalancerRoutingApplyConfiguration { + b := &LoadBalancerRoutingApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("LoadBalancerRouting") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractLoadBalancerRouting extracts the applied configuration owned by fieldManager from +// loadBalancerRouting. If no managedFields are found in loadBalancerRouting for fieldManager, a +// LoadBalancerRoutingApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// loadBalancerRouting must be a unmodified LoadBalancerRouting API object that was retrieved from the Kubernetes API. +// ExtractLoadBalancerRouting provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractLoadBalancerRouting(loadBalancerRouting *corev1alpha1.LoadBalancerRouting, fieldManager string) (*LoadBalancerRoutingApplyConfiguration, error) { + return extractLoadBalancerRouting(loadBalancerRouting, fieldManager, "") +} + +// ExtractLoadBalancerRoutingStatus is the same as ExtractLoadBalancerRouting except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractLoadBalancerRoutingStatus(loadBalancerRouting *corev1alpha1.LoadBalancerRouting, fieldManager string) (*LoadBalancerRoutingApplyConfiguration, error) { + return extractLoadBalancerRouting(loadBalancerRouting, fieldManager, "status") +} + +func extractLoadBalancerRouting(loadBalancerRouting *corev1alpha1.LoadBalancerRouting, fieldManager string, subresource string) (*LoadBalancerRoutingApplyConfiguration, error) { + b := &LoadBalancerRoutingApplyConfiguration{} + err := managedfields.ExtractInto(loadBalancerRouting, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerRouting"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(loadBalancerRouting.Name) + b.WithNamespace(loadBalancerRouting.Namespace) + + b.WithKind("LoadBalancerRouting") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithKind(value string) *LoadBalancerRoutingApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithAPIVersion(value string) *LoadBalancerRoutingApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithName(value string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithGenerateName(value string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithNamespace(value string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithUID(value types.UID) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithResourceVersion(value string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithGeneration(value int64) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithCreationTimestamp(value metav1.Time) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *LoadBalancerRoutingApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *LoadBalancerRoutingApplyConfiguration) WithLabels(entries map[string]string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *LoadBalancerRoutingApplyConfiguration) WithAnnotations(entries map[string]string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *LoadBalancerRoutingApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *LoadBalancerRoutingApplyConfiguration) WithFinalizers(values ...string) *LoadBalancerRoutingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *LoadBalancerRoutingApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *LoadBalancerRoutingApplyConfiguration) WithIPs(values ...net.IP) *LoadBalancerRoutingApplyConfiguration { + for i := range values { + b.IPs = append(b.IPs, values[i]) + } + return b +} + +// WithDestinations adds the given value to the Destinations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Destinations field. +func (b *LoadBalancerRoutingApplyConfiguration) WithDestinations(values ...*LoadBalancerDestinationApplyConfiguration) *LoadBalancerRoutingApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithDestinations") + } + b.Destinations = append(b.Destinations, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerspec.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerspec.go new file mode 100644 index 00000000..8d712994 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerspec.go @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + metav1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + v1 "k8s.io/api/core/v1" +) + +// LoadBalancerSpecApplyConfiguration represents an declarative configuration of the LoadBalancerSpec type for use +// with apply. +type LoadBalancerSpecApplyConfiguration struct { + Type *v1alpha1.LoadBalancerType `json:"type,omitempty"` + NetworkRef *v1.LocalObjectReference `json:"networkRef,omitempty"` + IPs []LoadBalancerIPApplyConfiguration `json:"ips,omitempty"` + Ports []LoadBalancerPortApplyConfiguration `json:"ports,omitempty"` + Selector *metav1.LabelSelectorApplyConfiguration `json:"nodeSelector,omitempty"` + Template *InstanceTemplateApplyConfiguration `json:"template,omitempty"` +} + +// LoadBalancerSpecApplyConfiguration constructs an declarative configuration of the LoadBalancerSpec type for use with +// apply. +func LoadBalancerSpec() *LoadBalancerSpecApplyConfiguration { + return &LoadBalancerSpecApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *LoadBalancerSpecApplyConfiguration) WithType(value v1alpha1.LoadBalancerType) *LoadBalancerSpecApplyConfiguration { + b.Type = &value + return b +} + +// WithNetworkRef sets the NetworkRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NetworkRef field is set to the value of the last call. +func (b *LoadBalancerSpecApplyConfiguration) WithNetworkRef(value v1.LocalObjectReference) *LoadBalancerSpecApplyConfiguration { + b.NetworkRef = &value + return b +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *LoadBalancerSpecApplyConfiguration) WithIPs(values ...*LoadBalancerIPApplyConfiguration) *LoadBalancerSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithIPs") + } + b.IPs = append(b.IPs, *values[i]) + } + return b +} + +// WithPorts adds the given value to the Ports field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Ports field. +func (b *LoadBalancerSpecApplyConfiguration) WithPorts(values ...*LoadBalancerPortApplyConfiguration) *LoadBalancerSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPorts") + } + b.Ports = append(b.Ports, *values[i]) + } + return b +} + +// WithSelector sets the Selector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Selector field is set to the value of the last call. +func (b *LoadBalancerSpecApplyConfiguration) WithSelector(value *metav1.LabelSelectorApplyConfiguration) *LoadBalancerSpecApplyConfiguration { + b.Selector = value + return b +} + +// WithTemplate sets the Template field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Template field is set to the value of the last call. +func (b *LoadBalancerSpecApplyConfiguration) WithTemplate(value *InstanceTemplateApplyConfiguration) *LoadBalancerSpecApplyConfiguration { + b.Template = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancerstatus.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancerstatus.go new file mode 100644 index 00000000..ced5e708 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancerstatus.go @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// LoadBalancerStatusApplyConfiguration represents an declarative configuration of the LoadBalancerStatus type for use +// with apply. +type LoadBalancerStatusApplyConfiguration struct { + CollisionCount *int32 `json:"collisionCount,omitempty"` + IPs []net.IP `json:"ips,omitempty"` +} + +// LoadBalancerStatusApplyConfiguration constructs an declarative configuration of the LoadBalancerStatus type for use with +// apply. +func LoadBalancerStatus() *LoadBalancerStatusApplyConfiguration { + return &LoadBalancerStatusApplyConfiguration{} +} + +// WithCollisionCount sets the CollisionCount field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CollisionCount field is set to the value of the last call. +func (b *LoadBalancerStatusApplyConfiguration) WithCollisionCount(value int32) *LoadBalancerStatusApplyConfiguration { + b.CollisionCount = &value + return b +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *LoadBalancerStatusApplyConfiguration) WithIPs(values ...net.IP) *LoadBalancerStatusApplyConfiguration { + for i := range values { + b.IPs = append(b.IPs, values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/loadbalancertargetref.go b/client-go/applyconfigurations/core/v1alpha1/loadbalancertargetref.go new file mode 100644 index 00000000..9179bd12 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/loadbalancertargetref.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + types "k8s.io/apimachinery/pkg/types" +) + +// LoadBalancerTargetRefApplyConfiguration represents an declarative configuration of the LoadBalancerTargetRef type for use +// with apply. +type LoadBalancerTargetRefApplyConfiguration struct { + UID *types.UID `json:"uid,omitempty"` + Name *string `json:"name,omitempty"` + NodeRef *v1.LocalObjectReference `json:"nodeRef,omitempty"` +} + +// LoadBalancerTargetRefApplyConfiguration constructs an declarative configuration of the LoadBalancerTargetRef type for use with +// apply. +func LoadBalancerTargetRef() *LoadBalancerTargetRefApplyConfiguration { + return &LoadBalancerTargetRefApplyConfiguration{} +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *LoadBalancerTargetRefApplyConfiguration) WithUID(value types.UID) *LoadBalancerTargetRefApplyConfiguration { + b.UID = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LoadBalancerTargetRefApplyConfiguration) WithName(value string) *LoadBalancerTargetRefApplyConfiguration { + b.Name = &value + return b +} + +// WithNodeRef sets the NodeRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeRef field is set to the value of the last call. +func (b *LoadBalancerTargetRefApplyConfiguration) WithNodeRef(value v1.LocalObjectReference) *LoadBalancerTargetRefApplyConfiguration { + b.NodeRef = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgateway.go b/client-go/applyconfigurations/core/v1alpha1/natgateway.go new file mode 100644 index 00000000..b06d4784 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgateway.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NATGatewayApplyConfiguration represents an declarative configuration of the NATGateway type for use +// with apply. +type NATGatewayApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *NATGatewaySpecApplyConfiguration `json:"spec,omitempty"` + Status *NATGatewayStatusApplyConfiguration `json:"status,omitempty"` +} + +// NATGateway constructs an declarative configuration of the NATGateway type for use with +// apply. +func NATGateway(name, namespace string) *NATGatewayApplyConfiguration { + b := &NATGatewayApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("NATGateway") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNATGateway extracts the applied configuration owned by fieldManager from +// nATGateway. If no managedFields are found in nATGateway for fieldManager, a +// NATGatewayApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// nATGateway must be a unmodified NATGateway API object that was retrieved from the Kubernetes API. +// ExtractNATGateway provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNATGateway(nATGateway *corev1alpha1.NATGateway, fieldManager string) (*NATGatewayApplyConfiguration, error) { + return extractNATGateway(nATGateway, fieldManager, "") +} + +// ExtractNATGatewayStatus is the same as ExtractNATGateway except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNATGatewayStatus(nATGateway *corev1alpha1.NATGateway, fieldManager string) (*NATGatewayApplyConfiguration, error) { + return extractNATGateway(nATGateway, fieldManager, "status") +} + +func extractNATGateway(nATGateway *corev1alpha1.NATGateway, fieldManager string, subresource string) (*NATGatewayApplyConfiguration, error) { + b := &NATGatewayApplyConfiguration{} + err := managedfields.ExtractInto(nATGateway, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGateway"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(nATGateway.Name) + b.WithNamespace(nATGateway.Namespace) + + b.WithKind("NATGateway") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithKind(value string) *NATGatewayApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithAPIVersion(value string) *NATGatewayApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithName(value string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithGenerateName(value string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithNamespace(value string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithUID(value types.UID) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithResourceVersion(value string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithGeneration(value int64) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NATGatewayApplyConfiguration) WithLabels(entries map[string]string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NATGatewayApplyConfiguration) WithAnnotations(entries map[string]string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NATGatewayApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NATGatewayApplyConfiguration) WithFinalizers(values ...string) *NATGatewayApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NATGatewayApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithSpec(value *NATGatewaySpecApplyConfiguration) *NATGatewayApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *NATGatewayApplyConfiguration) WithStatus(value *NATGatewayStatusApplyConfiguration) *NATGatewayApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscaler.go b/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscaler.go new file mode 100644 index 00000000..c034e7c2 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscaler.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NATGatewayAutoscalerApplyConfiguration represents an declarative configuration of the NATGatewayAutoscaler type for use +// with apply. +type NATGatewayAutoscalerApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *NATGatewayAutoscalerSpecApplyConfiguration `json:"spec,omitempty"` + Status *corev1alpha1.NATGatewayAutoscalerStatus `json:"status,omitempty"` +} + +// NATGatewayAutoscaler constructs an declarative configuration of the NATGatewayAutoscaler type for use with +// apply. +func NATGatewayAutoscaler(name, namespace string) *NATGatewayAutoscalerApplyConfiguration { + b := &NATGatewayAutoscalerApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("NATGatewayAutoscaler") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNATGatewayAutoscaler extracts the applied configuration owned by fieldManager from +// nATGatewayAutoscaler. If no managedFields are found in nATGatewayAutoscaler for fieldManager, a +// NATGatewayAutoscalerApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// nATGatewayAutoscaler must be a unmodified NATGatewayAutoscaler API object that was retrieved from the Kubernetes API. +// ExtractNATGatewayAutoscaler provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNATGatewayAutoscaler(nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscaler, fieldManager string) (*NATGatewayAutoscalerApplyConfiguration, error) { + return extractNATGatewayAutoscaler(nATGatewayAutoscaler, fieldManager, "") +} + +// ExtractNATGatewayAutoscalerStatus is the same as ExtractNATGatewayAutoscaler except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNATGatewayAutoscalerStatus(nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscaler, fieldManager string) (*NATGatewayAutoscalerApplyConfiguration, error) { + return extractNATGatewayAutoscaler(nATGatewayAutoscaler, fieldManager, "status") +} + +func extractNATGatewayAutoscaler(nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscaler, fieldManager string, subresource string) (*NATGatewayAutoscalerApplyConfiguration, error) { + b := &NATGatewayAutoscalerApplyConfiguration{} + err := managedfields.ExtractInto(nATGatewayAutoscaler, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscaler"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(nATGatewayAutoscaler.Name) + b.WithNamespace(nATGatewayAutoscaler.Namespace) + + b.WithKind("NATGatewayAutoscaler") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithKind(value string) *NATGatewayAutoscalerApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithAPIVersion(value string) *NATGatewayAutoscalerApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithName(value string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithGenerateName(value string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithNamespace(value string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithUID(value types.UID) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithResourceVersion(value string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithGeneration(value int64) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NATGatewayAutoscalerApplyConfiguration) WithLabels(entries map[string]string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NATGatewayAutoscalerApplyConfiguration) WithAnnotations(entries map[string]string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NATGatewayAutoscalerApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NATGatewayAutoscalerApplyConfiguration) WithFinalizers(values ...string) *NATGatewayAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NATGatewayAutoscalerApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithSpec(value *NATGatewayAutoscalerSpecApplyConfiguration) *NATGatewayAutoscalerApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *NATGatewayAutoscalerApplyConfiguration) WithStatus(value corev1alpha1.NATGatewayAutoscalerStatus) *NATGatewayAutoscalerApplyConfiguration { + b.Status = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscalerspec.go b/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscalerspec.go new file mode 100644 index 00000000..db6fc042 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgatewayautoscalerspec.go @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// NATGatewayAutoscalerSpecApplyConfiguration represents an declarative configuration of the NATGatewayAutoscalerSpec type for use +// with apply. +type NATGatewayAutoscalerSpecApplyConfiguration struct { + NATGatewayRef *v1.LocalObjectReference `json:"natGatewayRef,omitempty"` + MinPublicIPs *int32 `json:"minPublicIPs,omitempty"` + MaxPublicIPs *int32 `json:"maxPublicIPs,omitempty"` +} + +// NATGatewayAutoscalerSpecApplyConfiguration constructs an declarative configuration of the NATGatewayAutoscalerSpec type for use with +// apply. +func NATGatewayAutoscalerSpec() *NATGatewayAutoscalerSpecApplyConfiguration { + return &NATGatewayAutoscalerSpecApplyConfiguration{} +} + +// WithNATGatewayRef sets the NATGatewayRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NATGatewayRef field is set to the value of the last call. +func (b *NATGatewayAutoscalerSpecApplyConfiguration) WithNATGatewayRef(value v1.LocalObjectReference) *NATGatewayAutoscalerSpecApplyConfiguration { + b.NATGatewayRef = &value + return b +} + +// WithMinPublicIPs sets the MinPublicIPs field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MinPublicIPs field is set to the value of the last call. +func (b *NATGatewayAutoscalerSpecApplyConfiguration) WithMinPublicIPs(value int32) *NATGatewayAutoscalerSpecApplyConfiguration { + b.MinPublicIPs = &value + return b +} + +// WithMaxPublicIPs sets the MaxPublicIPs field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MaxPublicIPs field is set to the value of the last call. +func (b *NATGatewayAutoscalerSpecApplyConfiguration) WithMaxPublicIPs(value int32) *NATGatewayAutoscalerSpecApplyConfiguration { + b.MaxPublicIPs = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgatewayip.go b/client-go/applyconfigurations/core/v1alpha1/natgatewayip.go new file mode 100644 index 00000000..3c56b159 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgatewayip.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// NATGatewayIPApplyConfiguration represents an declarative configuration of the NATGatewayIP type for use +// with apply. +type NATGatewayIPApplyConfiguration struct { + Name *string `json:"name,omitempty"` + IP *net.IP `json:"ip,omitempty"` +} + +// NATGatewayIPApplyConfiguration constructs an declarative configuration of the NATGatewayIP type for use with +// apply. +func NATGatewayIP() *NATGatewayIPApplyConfiguration { + return &NATGatewayIPApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NATGatewayIPApplyConfiguration) WithName(value string) *NATGatewayIPApplyConfiguration { + b.Name = &value + return b +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *NATGatewayIPApplyConfiguration) WithIP(value net.IP) *NATGatewayIPApplyConfiguration { + b.IP = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgatewayspec.go b/client-go/applyconfigurations/core/v1alpha1/natgatewayspec.go new file mode 100644 index 00000000..1e7165fb --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgatewayspec.go @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// NATGatewaySpecApplyConfiguration represents an declarative configuration of the NATGatewaySpec type for use +// with apply. +type NATGatewaySpecApplyConfiguration struct { + IPFamily *v1.IPFamily `json:"ipFamily,omitempty"` + NetworkRef *v1.LocalObjectReference `json:"networkRef,omitempty"` + IPs []NATGatewayIPApplyConfiguration `json:"ips,omitempty"` + PortsPerNetworkInterface *int32 `json:"portsPerNetworkInterface,omitempty"` +} + +// NATGatewaySpecApplyConfiguration constructs an declarative configuration of the NATGatewaySpec type for use with +// apply. +func NATGatewaySpec() *NATGatewaySpecApplyConfiguration { + return &NATGatewaySpecApplyConfiguration{} +} + +// WithIPFamily sets the IPFamily field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPFamily field is set to the value of the last call. +func (b *NATGatewaySpecApplyConfiguration) WithIPFamily(value v1.IPFamily) *NATGatewaySpecApplyConfiguration { + b.IPFamily = &value + return b +} + +// WithNetworkRef sets the NetworkRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NetworkRef field is set to the value of the last call. +func (b *NATGatewaySpecApplyConfiguration) WithNetworkRef(value v1.LocalObjectReference) *NATGatewaySpecApplyConfiguration { + b.NetworkRef = &value + return b +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *NATGatewaySpecApplyConfiguration) WithIPs(values ...*NATGatewayIPApplyConfiguration) *NATGatewaySpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithIPs") + } + b.IPs = append(b.IPs, *values[i]) + } + return b +} + +// WithPortsPerNetworkInterface sets the PortsPerNetworkInterface field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the PortsPerNetworkInterface field is set to the value of the last call. +func (b *NATGatewaySpecApplyConfiguration) WithPortsPerNetworkInterface(value int32) *NATGatewaySpecApplyConfiguration { + b.PortsPerNetworkInterface = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natgatewaystatus.go b/client-go/applyconfigurations/core/v1alpha1/natgatewaystatus.go new file mode 100644 index 00000000..e3bb2321 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natgatewaystatus.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NATGatewayStatusApplyConfiguration represents an declarative configuration of the NATGatewayStatus type for use +// with apply. +type NATGatewayStatusApplyConfiguration struct { + UsedNATIPs *int64 `json:"usedNATIPs,omitempty"` + RequestedNATIPs *int64 `json:"requestedNATIPs,omitempty"` +} + +// NATGatewayStatusApplyConfiguration constructs an declarative configuration of the NATGatewayStatus type for use with +// apply. +func NATGatewayStatus() *NATGatewayStatusApplyConfiguration { + return &NATGatewayStatusApplyConfiguration{} +} + +// WithUsedNATIPs sets the UsedNATIPs field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UsedNATIPs field is set to the value of the last call. +func (b *NATGatewayStatusApplyConfiguration) WithUsedNATIPs(value int64) *NATGatewayStatusApplyConfiguration { + b.UsedNATIPs = &value + return b +} + +// WithRequestedNATIPs sets the RequestedNATIPs field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RequestedNATIPs field is set to the value of the last call. +func (b *NATGatewayStatusApplyConfiguration) WithRequestedNATIPs(value int64) *NATGatewayStatusApplyConfiguration { + b.RequestedNATIPs = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natip.go b/client-go/applyconfigurations/core/v1alpha1/natip.go new file mode 100644 index 00000000..2be1a623 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natip.go @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// NATIPApplyConfiguration represents an declarative configuration of the NATIP type for use +// with apply. +type NATIPApplyConfiguration struct { + IP *net.IP `json:"ip,omitempty"` + Sections []NATIPSectionApplyConfiguration `json:"sections,omitempty"` +} + +// NATIPApplyConfiguration constructs an declarative configuration of the NATIP type for use with +// apply. +func NATIP() *NATIPApplyConfiguration { + return &NATIPApplyConfiguration{} +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *NATIPApplyConfiguration) WithIP(value net.IP) *NATIPApplyConfiguration { + b.IP = &value + return b +} + +// WithSections adds the given value to the Sections field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Sections field. +func (b *NATIPApplyConfiguration) WithSections(values ...*NATIPSectionApplyConfiguration) *NATIPApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSections") + } + b.Sections = append(b.Sections, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/natipsection.go b/client-go/applyconfigurations/core/v1alpha1/natipsection.go new file mode 100644 index 00000000..0f0dc07c --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/natipsection.go @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// NATIPSectionApplyConfiguration represents an declarative configuration of the NATIPSection type for use +// with apply. +type NATIPSectionApplyConfiguration struct { + IP *net.IP `json:"ip,omitempty"` + Port *int32 `json:"port,omitempty"` + EndPort *int32 `json:"endPort,omitempty"` + TargetRef *NATTableIPTargetRefApplyConfiguration `json:"targetRef,omitempty"` +} + +// NATIPSectionApplyConfiguration constructs an declarative configuration of the NATIPSection type for use with +// apply. +func NATIPSection() *NATIPSectionApplyConfiguration { + return &NATIPSectionApplyConfiguration{} +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *NATIPSectionApplyConfiguration) WithIP(value net.IP) *NATIPSectionApplyConfiguration { + b.IP = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *NATIPSectionApplyConfiguration) WithPort(value int32) *NATIPSectionApplyConfiguration { + b.Port = &value + return b +} + +// WithEndPort sets the EndPort field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the EndPort field is set to the value of the last call. +func (b *NATIPSectionApplyConfiguration) WithEndPort(value int32) *NATIPSectionApplyConfiguration { + b.EndPort = &value + return b +} + +// WithTargetRef sets the TargetRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TargetRef field is set to the value of the last call. +func (b *NATIPSectionApplyConfiguration) WithTargetRef(value *NATTableIPTargetRefApplyConfiguration) *NATIPSectionApplyConfiguration { + b.TargetRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nattable.go b/client-go/applyconfigurations/core/v1alpha1/nattable.go new file mode 100644 index 00000000..8f09fc3f --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nattable.go @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NATTableApplyConfiguration represents an declarative configuration of the NATTable type for use +// with apply. +type NATTableApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + IPs []NATIPApplyConfiguration `json:"ips,omitempty"` +} + +// NATTable constructs an declarative configuration of the NATTable type for use with +// apply. +func NATTable(name, namespace string) *NATTableApplyConfiguration { + b := &NATTableApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("NATTable") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNATTable extracts the applied configuration owned by fieldManager from +// nATTable. If no managedFields are found in nATTable for fieldManager, a +// NATTableApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// nATTable must be a unmodified NATTable API object that was retrieved from the Kubernetes API. +// ExtractNATTable provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNATTable(nATTable *corev1alpha1.NATTable, fieldManager string) (*NATTableApplyConfiguration, error) { + return extractNATTable(nATTable, fieldManager, "") +} + +// ExtractNATTableStatus is the same as ExtractNATTable except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNATTableStatus(nATTable *corev1alpha1.NATTable, fieldManager string) (*NATTableApplyConfiguration, error) { + return extractNATTable(nATTable, fieldManager, "status") +} + +func extractNATTable(nATTable *corev1alpha1.NATTable, fieldManager string, subresource string) (*NATTableApplyConfiguration, error) { + b := &NATTableApplyConfiguration{} + err := managedfields.ExtractInto(nATTable, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATTable"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(nATTable.Name) + b.WithNamespace(nATTable.Namespace) + + b.WithKind("NATTable") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithKind(value string) *NATTableApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithAPIVersion(value string) *NATTableApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithName(value string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithGenerateName(value string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithNamespace(value string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithUID(value types.UID) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithResourceVersion(value string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithGeneration(value int64) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NATTableApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NATTableApplyConfiguration) WithLabels(entries map[string]string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NATTableApplyConfiguration) WithAnnotations(entries map[string]string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NATTableApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NATTableApplyConfiguration) WithFinalizers(values ...string) *NATTableApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NATTableApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *NATTableApplyConfiguration) WithIPs(values ...*NATIPApplyConfiguration) *NATTableApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithIPs") + } + b.IPs = append(b.IPs, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nattableiptargetref.go b/client-go/applyconfigurations/core/v1alpha1/nattableiptargetref.go new file mode 100644 index 00000000..902ce601 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nattableiptargetref.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + types "k8s.io/apimachinery/pkg/types" +) + +// NATTableIPTargetRefApplyConfiguration represents an declarative configuration of the NATTableIPTargetRef type for use +// with apply. +type NATTableIPTargetRefApplyConfiguration struct { + UID *types.UID `json:"uid,omitempty"` + Name *string `json:"name,omitempty"` + NodeRef *v1.LocalObjectReference `json:"nodeRef,omitempty"` +} + +// NATTableIPTargetRefApplyConfiguration constructs an declarative configuration of the NATTableIPTargetRef type for use with +// apply. +func NATTableIPTargetRef() *NATTableIPTargetRefApplyConfiguration { + return &NATTableIPTargetRefApplyConfiguration{} +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NATTableIPTargetRefApplyConfiguration) WithUID(value types.UID) *NATTableIPTargetRefApplyConfiguration { + b.UID = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NATTableIPTargetRefApplyConfiguration) WithName(value string) *NATTableIPTargetRefApplyConfiguration { + b.Name = &value + return b +} + +// WithNodeRef sets the NodeRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeRef field is set to the value of the last call. +func (b *NATTableIPTargetRefApplyConfiguration) WithNodeRef(value v1.LocalObjectReference) *NATTableIPTargetRefApplyConfiguration { + b.NodeRef = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/network.go b/client-go/applyconfigurations/core/v1alpha1/network.go new file mode 100644 index 00000000..d6aa4fd3 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/network.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NetworkApplyConfiguration represents an declarative configuration of the Network type for use +// with apply. +type NetworkApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *NetworkSpecApplyConfiguration `json:"spec,omitempty"` + Status *corev1alpha1.NetworkStatus `json:"status,omitempty"` +} + +// Network constructs an declarative configuration of the Network type for use with +// apply. +func Network(name, namespace string) *NetworkApplyConfiguration { + b := &NetworkApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Network") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNetwork extracts the applied configuration owned by fieldManager from +// network. If no managedFields are found in network for fieldManager, a +// NetworkApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// network must be a unmodified Network API object that was retrieved from the Kubernetes API. +// ExtractNetwork provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNetwork(network *corev1alpha1.Network, fieldManager string) (*NetworkApplyConfiguration, error) { + return extractNetwork(network, fieldManager, "") +} + +// ExtractNetworkStatus is the same as ExtractNetwork except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNetworkStatus(network *corev1alpha1.Network, fieldManager string) (*NetworkApplyConfiguration, error) { + return extractNetwork(network, fieldManager, "status") +} + +func extractNetwork(network *corev1alpha1.Network, fieldManager string, subresource string) (*NetworkApplyConfiguration, error) { + b := &NetworkApplyConfiguration{} + err := managedfields.ExtractInto(network, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Network"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(network.Name) + b.WithNamespace(network.Namespace) + + b.WithKind("Network") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithKind(value string) *NetworkApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithAPIVersion(value string) *NetworkApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithName(value string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithGenerateName(value string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithNamespace(value string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithUID(value types.UID) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithResourceVersion(value string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithGeneration(value int64) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NetworkApplyConfiguration) WithLabels(entries map[string]string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NetworkApplyConfiguration) WithAnnotations(entries map[string]string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NetworkApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NetworkApplyConfiguration) WithFinalizers(values ...string) *NetworkApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NetworkApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithSpec(value *NetworkSpecApplyConfiguration) *NetworkApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *NetworkApplyConfiguration) WithStatus(value corev1alpha1.NetworkStatus) *NetworkApplyConfiguration { + b.Status = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkid.go b/client-go/applyconfigurations/core/v1alpha1/networkid.go new file mode 100644 index 00000000..dca7a63c --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkid.go @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NetworkIDApplyConfiguration represents an declarative configuration of the NetworkID type for use +// with apply. +type NetworkIDApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *NetworkIDSpecApplyConfiguration `json:"spec,omitempty"` +} + +// NetworkID constructs an declarative configuration of the NetworkID type for use with +// apply. +func NetworkID(name string) *NetworkIDApplyConfiguration { + b := &NetworkIDApplyConfiguration{} + b.WithName(name) + b.WithKind("NetworkID") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNetworkID extracts the applied configuration owned by fieldManager from +// networkID. If no managedFields are found in networkID for fieldManager, a +// NetworkIDApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// networkID must be a unmodified NetworkID API object that was retrieved from the Kubernetes API. +// ExtractNetworkID provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNetworkID(networkID *corev1alpha1.NetworkID, fieldManager string) (*NetworkIDApplyConfiguration, error) { + return extractNetworkID(networkID, fieldManager, "") +} + +// ExtractNetworkIDStatus is the same as ExtractNetworkID except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNetworkIDStatus(networkID *corev1alpha1.NetworkID, fieldManager string) (*NetworkIDApplyConfiguration, error) { + return extractNetworkID(networkID, fieldManager, "status") +} + +func extractNetworkID(networkID *corev1alpha1.NetworkID, fieldManager string, subresource string) (*NetworkIDApplyConfiguration, error) { + b := &NetworkIDApplyConfiguration{} + err := managedfields.ExtractInto(networkID, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkID"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(networkID.Name) + + b.WithKind("NetworkID") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithKind(value string) *NetworkIDApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithAPIVersion(value string) *NetworkIDApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithName(value string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithGenerateName(value string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithNamespace(value string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithUID(value types.UID) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithResourceVersion(value string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithGeneration(value int64) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NetworkIDApplyConfiguration) WithLabels(entries map[string]string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NetworkIDApplyConfiguration) WithAnnotations(entries map[string]string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NetworkIDApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NetworkIDApplyConfiguration) WithFinalizers(values ...string) *NetworkIDApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NetworkIDApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NetworkIDApplyConfiguration) WithSpec(value *NetworkIDSpecApplyConfiguration) *NetworkIDApplyConfiguration { + b.Spec = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkidclaimref.go b/client-go/applyconfigurations/core/v1alpha1/networkidclaimref.go new file mode 100644 index 00000000..b8bf8c74 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkidclaimref.go @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + types "k8s.io/apimachinery/pkg/types" +) + +// NetworkIDClaimRefApplyConfiguration represents an declarative configuration of the NetworkIDClaimRef type for use +// with apply. +type NetworkIDClaimRefApplyConfiguration struct { + Group *string `json:"group,omitempty"` + Resource *string `json:"resource,omitempty"` + Namespace *string `json:"namespace,omitempty"` + Name *string `json:"name,omitempty"` + UID *types.UID `json:"uid,omitempty"` +} + +// NetworkIDClaimRefApplyConfiguration constructs an declarative configuration of the NetworkIDClaimRef type for use with +// apply. +func NetworkIDClaimRef() *NetworkIDClaimRefApplyConfiguration { + return &NetworkIDClaimRefApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *NetworkIDClaimRefApplyConfiguration) WithGroup(value string) *NetworkIDClaimRefApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *NetworkIDClaimRefApplyConfiguration) WithResource(value string) *NetworkIDClaimRefApplyConfiguration { + b.Resource = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NetworkIDClaimRefApplyConfiguration) WithNamespace(value string) *NetworkIDClaimRefApplyConfiguration { + b.Namespace = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkIDClaimRefApplyConfiguration) WithName(value string) *NetworkIDClaimRefApplyConfiguration { + b.Name = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NetworkIDClaimRefApplyConfiguration) WithUID(value types.UID) *NetworkIDClaimRefApplyConfiguration { + b.UID = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkidspec.go b/client-go/applyconfigurations/core/v1alpha1/networkidspec.go new file mode 100644 index 00000000..75cba5ae --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkidspec.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NetworkIDSpecApplyConfiguration represents an declarative configuration of the NetworkIDSpec type for use +// with apply. +type NetworkIDSpecApplyConfiguration struct { + ClaimRef *NetworkIDClaimRefApplyConfiguration `json:"claimRef,omitempty"` +} + +// NetworkIDSpecApplyConfiguration constructs an declarative configuration of the NetworkIDSpec type for use with +// apply. +func NetworkIDSpec() *NetworkIDSpecApplyConfiguration { + return &NetworkIDSpecApplyConfiguration{} +} + +// WithClaimRef sets the ClaimRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClaimRef field is set to the value of the last call. +func (b *NetworkIDSpecApplyConfiguration) WithClaimRef(value *NetworkIDClaimRefApplyConfiguration) *NetworkIDSpecApplyConfiguration { + b.ClaimRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterface.go b/client-go/applyconfigurations/core/v1alpha1/networkinterface.go new file mode 100644 index 00000000..97ef7834 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterface.go @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NetworkInterfaceApplyConfiguration represents an declarative configuration of the NetworkInterface type for use +// with apply. +type NetworkInterfaceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *NetworkInterfaceSpecApplyConfiguration `json:"spec,omitempty"` + Status *NetworkInterfaceStatusApplyConfiguration `json:"status,omitempty"` +} + +// NetworkInterface constructs an declarative configuration of the NetworkInterface type for use with +// apply. +func NetworkInterface(name, namespace string) *NetworkInterfaceApplyConfiguration { + b := &NetworkInterfaceApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("NetworkInterface") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNetworkInterface extracts the applied configuration owned by fieldManager from +// networkInterface. If no managedFields are found in networkInterface for fieldManager, a +// NetworkInterfaceApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// networkInterface must be a unmodified NetworkInterface API object that was retrieved from the Kubernetes API. +// ExtractNetworkInterface provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNetworkInterface(networkInterface *corev1alpha1.NetworkInterface, fieldManager string) (*NetworkInterfaceApplyConfiguration, error) { + return extractNetworkInterface(networkInterface, fieldManager, "") +} + +// ExtractNetworkInterfaceStatus is the same as ExtractNetworkInterface except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNetworkInterfaceStatus(networkInterface *corev1alpha1.NetworkInterface, fieldManager string) (*NetworkInterfaceApplyConfiguration, error) { + return extractNetworkInterface(networkInterface, fieldManager, "status") +} + +func extractNetworkInterface(networkInterface *corev1alpha1.NetworkInterface, fieldManager string, subresource string) (*NetworkInterfaceApplyConfiguration, error) { + b := &NetworkInterfaceApplyConfiguration{} + err := managedfields.ExtractInto(networkInterface, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterface"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(networkInterface.Name) + b.WithNamespace(networkInterface.Namespace) + + b.WithKind("NetworkInterface") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithKind(value string) *NetworkInterfaceApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithAPIVersion(value string) *NetworkInterfaceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithName(value string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithGenerateName(value string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithNamespace(value string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithUID(value types.UID) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithResourceVersion(value string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithGeneration(value int64) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NetworkInterfaceApplyConfiguration) WithLabels(entries map[string]string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NetworkInterfaceApplyConfiguration) WithAnnotations(entries map[string]string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NetworkInterfaceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NetworkInterfaceApplyConfiguration) WithFinalizers(values ...string) *NetworkInterfaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NetworkInterfaceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithSpec(value *NetworkInterfaceSpecApplyConfiguration) *NetworkInterfaceApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *NetworkInterfaceApplyConfiguration) WithStatus(value *NetworkInterfaceStatusApplyConfiguration) *NetworkInterfaceApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterfacenat.go b/client-go/applyconfigurations/core/v1alpha1/networkinterfacenat.go new file mode 100644 index 00000000..6e4a88de --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterfacenat.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// NetworkInterfaceNATApplyConfiguration represents an declarative configuration of the NetworkInterfaceNAT type for use +// with apply. +type NetworkInterfaceNATApplyConfiguration struct { + IPFamily *v1.IPFamily `json:"ipFamily,omitempty"` + ClaimRef *NetworkInterfaceNATClaimRefApplyConfiguration `json:"claimRef,omitempty"` +} + +// NetworkInterfaceNATApplyConfiguration constructs an declarative configuration of the NetworkInterfaceNAT type for use with +// apply. +func NetworkInterfaceNAT() *NetworkInterfaceNATApplyConfiguration { + return &NetworkInterfaceNATApplyConfiguration{} +} + +// WithIPFamily sets the IPFamily field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPFamily field is set to the value of the last call. +func (b *NetworkInterfaceNATApplyConfiguration) WithIPFamily(value v1.IPFamily) *NetworkInterfaceNATApplyConfiguration { + b.IPFamily = &value + return b +} + +// WithClaimRef sets the ClaimRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClaimRef field is set to the value of the last call. +func (b *NetworkInterfaceNATApplyConfiguration) WithClaimRef(value *NetworkInterfaceNATClaimRefApplyConfiguration) *NetworkInterfaceNATApplyConfiguration { + b.ClaimRef = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterfacenatclaimref.go b/client-go/applyconfigurations/core/v1alpha1/networkinterfacenatclaimref.go new file mode 100644 index 00000000..2440090a --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterfacenatclaimref.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + types "k8s.io/apimachinery/pkg/types" +) + +// NetworkInterfaceNATClaimRefApplyConfiguration represents an declarative configuration of the NetworkInterfaceNATClaimRef type for use +// with apply. +type NetworkInterfaceNATClaimRefApplyConfiguration struct { + Name *string `json:"name,omitempty"` + UID *types.UID `json:"uid,omitempty"` +} + +// NetworkInterfaceNATClaimRefApplyConfiguration constructs an declarative configuration of the NetworkInterfaceNATClaimRef type for use with +// apply. +func NetworkInterfaceNATClaimRef() *NetworkInterfaceNATClaimRefApplyConfiguration { + return &NetworkInterfaceNATClaimRefApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkInterfaceNATClaimRefApplyConfiguration) WithName(value string) *NetworkInterfaceNATClaimRefApplyConfiguration { + b.Name = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NetworkInterfaceNATClaimRefApplyConfiguration) WithUID(value types.UID) *NetworkInterfaceNATClaimRefApplyConfiguration { + b.UID = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterfacepublicip.go b/client-go/applyconfigurations/core/v1alpha1/networkinterfacepublicip.go new file mode 100644 index 00000000..745e679d --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterfacepublicip.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + v1 "k8s.io/api/core/v1" +) + +// NetworkInterfacePublicIPApplyConfiguration represents an declarative configuration of the NetworkInterfacePublicIP type for use +// with apply. +type NetworkInterfacePublicIPApplyConfiguration struct { + Name *string `json:"name,omitempty"` + IPFamily *v1.IPFamily `json:"ipFamily,omitempty"` + IP *net.IP `json:"ip,omitempty"` +} + +// NetworkInterfacePublicIPApplyConfiguration constructs an declarative configuration of the NetworkInterfacePublicIP type for use with +// apply. +func NetworkInterfacePublicIP() *NetworkInterfacePublicIPApplyConfiguration { + return &NetworkInterfacePublicIPApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NetworkInterfacePublicIPApplyConfiguration) WithName(value string) *NetworkInterfacePublicIPApplyConfiguration { + b.Name = &value + return b +} + +// WithIPFamily sets the IPFamily field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IPFamily field is set to the value of the last call. +func (b *NetworkInterfacePublicIPApplyConfiguration) WithIPFamily(value v1.IPFamily) *NetworkInterfacePublicIPApplyConfiguration { + b.IPFamily = &value + return b +} + +// WithIP sets the IP field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the IP field is set to the value of the last call. +func (b *NetworkInterfacePublicIPApplyConfiguration) WithIP(value net.IP) *NetworkInterfacePublicIPApplyConfiguration { + b.IP = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterfacespec.go b/client-go/applyconfigurations/core/v1alpha1/networkinterfacespec.go new file mode 100644 index 00000000..8ae8dbc9 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterfacespec.go @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + v1 "k8s.io/api/core/v1" +) + +// NetworkInterfaceSpecApplyConfiguration represents an declarative configuration of the NetworkInterfaceSpec type for use +// with apply. +type NetworkInterfaceSpecApplyConfiguration struct { + NodeRef *v1.LocalObjectReference `json:"nodeRef,omitempty"` + NetworkRef *v1.LocalObjectReference `json:"networkRef,omitempty"` + IPs []net.IP `json:"ips,omitempty"` + Prefixes []net.IPPrefix `json:"prefixes,omitempty"` + NATs []NetworkInterfaceNATApplyConfiguration `json:"natGateways,omitempty"` + PublicIPs []NetworkInterfacePublicIPApplyConfiguration `json:"publicIPs,omitempty"` +} + +// NetworkInterfaceSpecApplyConfiguration constructs an declarative configuration of the NetworkInterfaceSpec type for use with +// apply. +func NetworkInterfaceSpec() *NetworkInterfaceSpecApplyConfiguration { + return &NetworkInterfaceSpecApplyConfiguration{} +} + +// WithNodeRef sets the NodeRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeRef field is set to the value of the last call. +func (b *NetworkInterfaceSpecApplyConfiguration) WithNodeRef(value v1.LocalObjectReference) *NetworkInterfaceSpecApplyConfiguration { + b.NodeRef = &value + return b +} + +// WithNetworkRef sets the NetworkRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NetworkRef field is set to the value of the last call. +func (b *NetworkInterfaceSpecApplyConfiguration) WithNetworkRef(value v1.LocalObjectReference) *NetworkInterfaceSpecApplyConfiguration { + b.NetworkRef = &value + return b +} + +// WithIPs adds the given value to the IPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the IPs field. +func (b *NetworkInterfaceSpecApplyConfiguration) WithIPs(values ...net.IP) *NetworkInterfaceSpecApplyConfiguration { + for i := range values { + b.IPs = append(b.IPs, values[i]) + } + return b +} + +// WithPrefixes adds the given value to the Prefixes field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Prefixes field. +func (b *NetworkInterfaceSpecApplyConfiguration) WithPrefixes(values ...net.IPPrefix) *NetworkInterfaceSpecApplyConfiguration { + for i := range values { + b.Prefixes = append(b.Prefixes, values[i]) + } + return b +} + +// WithNATs adds the given value to the NATs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the NATs field. +func (b *NetworkInterfaceSpecApplyConfiguration) WithNATs(values ...*NetworkInterfaceNATApplyConfiguration) *NetworkInterfaceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithNATs") + } + b.NATs = append(b.NATs, *values[i]) + } + return b +} + +// WithPublicIPs adds the given value to the PublicIPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the PublicIPs field. +func (b *NetworkInterfaceSpecApplyConfiguration) WithPublicIPs(values ...*NetworkInterfacePublicIPApplyConfiguration) *NetworkInterfaceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPublicIPs") + } + b.PublicIPs = append(b.PublicIPs, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkinterfacestatus.go b/client-go/applyconfigurations/core/v1alpha1/networkinterfacestatus.go new file mode 100644 index 00000000..ff62b938 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkinterfacestatus.go @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" +) + +// NetworkInterfaceStatusApplyConfiguration represents an declarative configuration of the NetworkInterfaceStatus type for use +// with apply. +type NetworkInterfaceStatusApplyConfiguration struct { + State *v1alpha1.NetworkInterfaceState `json:"state,omitempty"` + PCIAddress *PCIAddressApplyConfiguration `json:"pciAddress,omitempty"` + Prefixes []net.IPPrefix `json:"prefixes,omitempty"` + PublicIPs []net.IP `json:"publicIPs,omitempty"` + NATIPs []net.IP `json:"natIPs,omitempty"` +} + +// NetworkInterfaceStatusApplyConfiguration constructs an declarative configuration of the NetworkInterfaceStatus type for use with +// apply. +func NetworkInterfaceStatus() *NetworkInterfaceStatusApplyConfiguration { + return &NetworkInterfaceStatusApplyConfiguration{} +} + +// WithState sets the State field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the State field is set to the value of the last call. +func (b *NetworkInterfaceStatusApplyConfiguration) WithState(value v1alpha1.NetworkInterfaceState) *NetworkInterfaceStatusApplyConfiguration { + b.State = &value + return b +} + +// WithPCIAddress sets the PCIAddress field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the PCIAddress field is set to the value of the last call. +func (b *NetworkInterfaceStatusApplyConfiguration) WithPCIAddress(value *PCIAddressApplyConfiguration) *NetworkInterfaceStatusApplyConfiguration { + b.PCIAddress = value + return b +} + +// WithPrefixes adds the given value to the Prefixes field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Prefixes field. +func (b *NetworkInterfaceStatusApplyConfiguration) WithPrefixes(values ...net.IPPrefix) *NetworkInterfaceStatusApplyConfiguration { + for i := range values { + b.Prefixes = append(b.Prefixes, values[i]) + } + return b +} + +// WithPublicIPs adds the given value to the PublicIPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the PublicIPs field. +func (b *NetworkInterfaceStatusApplyConfiguration) WithPublicIPs(values ...net.IP) *NetworkInterfaceStatusApplyConfiguration { + for i := range values { + b.PublicIPs = append(b.PublicIPs, values[i]) + } + return b +} + +// WithNATIPs adds the given value to the NATIPs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the NATIPs field. +func (b *NetworkInterfaceStatusApplyConfiguration) WithNATIPs(values ...net.IP) *NetworkInterfaceStatusApplyConfiguration { + for i := range values { + b.NATIPs = append(b.NATIPs, values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/networkspec.go b/client-go/applyconfigurations/core/v1alpha1/networkspec.go new file mode 100644 index 00000000..8ac1b40a --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/networkspec.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NetworkSpecApplyConfiguration represents an declarative configuration of the NetworkSpec type for use +// with apply. +type NetworkSpecApplyConfiguration struct { + ID *string `json:"id,omitempty"` +} + +// NetworkSpecApplyConfiguration constructs an declarative configuration of the NetworkSpec type for use with +// apply. +func NetworkSpec() *NetworkSpecApplyConfiguration { + return &NetworkSpecApplyConfiguration{} +} + +// WithID sets the ID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ID field is set to the value of the last call. +func (b *NetworkSpecApplyConfiguration) WithID(value string) *NetworkSpecApplyConfiguration { + b.ID = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/node.go b/client-go/applyconfigurations/core/v1alpha1/node.go new file mode 100644 index 00000000..c6d12265 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/node.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internal "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/internal" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// NodeApplyConfiguration represents an declarative configuration of the Node type for use +// with apply. +type NodeApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *v1alpha1.NodeSpec `json:"spec,omitempty"` + Status *v1alpha1.NodeStatus `json:"status,omitempty"` +} + +// Node constructs an declarative configuration of the Node type for use with +// apply. +func Node(name string) *NodeApplyConfiguration { + b := &NodeApplyConfiguration{} + b.WithName(name) + b.WithKind("Node") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b +} + +// ExtractNode extracts the applied configuration owned by fieldManager from +// node. If no managedFields are found in node for fieldManager, a +// NodeApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// node must be a unmodified Node API object that was retrieved from the Kubernetes API. +// ExtractNode provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractNode(node *v1alpha1.Node, fieldManager string) (*NodeApplyConfiguration, error) { + return extractNode(node, fieldManager, "") +} + +// ExtractNodeStatus is the same as ExtractNode except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractNodeStatus(node *v1alpha1.Node, fieldManager string) (*NodeApplyConfiguration, error) { + return extractNode(node, fieldManager, "status") +} + +func extractNode(node *v1alpha1.Node, fieldManager string, subresource string) (*NodeApplyConfiguration, error) { + b := &NodeApplyConfiguration{} + err := managedfields.ExtractInto(node, internal.Parser().Type("com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Node"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(node.Name) + + b.WithKind("Node") + b.WithAPIVersion("core.apinet.api.onmetal.de/v1alpha1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithKind(value string) *NodeApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithAPIVersion(value string) *NodeApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithName(value string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithGenerateName(value string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithNamespace(value string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithUID(value types.UID) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithResourceVersion(value string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithGeneration(value int64) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *NodeApplyConfiguration) WithLabels(entries map[string]string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *NodeApplyConfiguration) WithAnnotations(entries map[string]string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *NodeApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *NodeApplyConfiguration) WithFinalizers(values ...string) *NodeApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *NodeApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithSpec(value v1alpha1.NodeSpec) *NodeApplyConfiguration { + b.Spec = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *NodeApplyConfiguration) WithStatus(value v1alpha1.NodeStatus) *NodeApplyConfiguration { + b.Status = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nodeaffinity.go b/client-go/applyconfigurations/core/v1alpha1/nodeaffinity.go new file mode 100644 index 00000000..6ee0a595 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nodeaffinity.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NodeAffinityApplyConfiguration represents an declarative configuration of the NodeAffinity type for use +// with apply. +type NodeAffinityApplyConfiguration struct { + RequiredDuringSchedulingIgnoredDuringExecution *NodeSelectorApplyConfiguration `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"` +} + +// NodeAffinityApplyConfiguration constructs an declarative configuration of the NodeAffinity type for use with +// apply. +func NodeAffinity() *NodeAffinityApplyConfiguration { + return &NodeAffinityApplyConfiguration{} +} + +// WithRequiredDuringSchedulingIgnoredDuringExecution sets the RequiredDuringSchedulingIgnoredDuringExecution field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RequiredDuringSchedulingIgnoredDuringExecution field is set to the value of the last call. +func (b *NodeAffinityApplyConfiguration) WithRequiredDuringSchedulingIgnoredDuringExecution(value *NodeSelectorApplyConfiguration) *NodeAffinityApplyConfiguration { + b.RequiredDuringSchedulingIgnoredDuringExecution = value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nodeselector.go b/client-go/applyconfigurations/core/v1alpha1/nodeselector.go new file mode 100644 index 00000000..e22edbf9 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nodeselector.go @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NodeSelectorApplyConfiguration represents an declarative configuration of the NodeSelector type for use +// with apply. +type NodeSelectorApplyConfiguration struct { + NodeSelectorTerms []NodeSelectorTermApplyConfiguration `json:"nodeSelectorTerms,omitempty"` +} + +// NodeSelectorApplyConfiguration constructs an declarative configuration of the NodeSelector type for use with +// apply. +func NodeSelector() *NodeSelectorApplyConfiguration { + return &NodeSelectorApplyConfiguration{} +} + +// WithNodeSelectorTerms adds the given value to the NodeSelectorTerms field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the NodeSelectorTerms field. +func (b *NodeSelectorApplyConfiguration) WithNodeSelectorTerms(values ...*NodeSelectorTermApplyConfiguration) *NodeSelectorApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithNodeSelectorTerms") + } + b.NodeSelectorTerms = append(b.NodeSelectorTerms, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nodeselectorrequirement.go b/client-go/applyconfigurations/core/v1alpha1/nodeselectorrequirement.go new file mode 100644 index 00000000..c8618441 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nodeselectorrequirement.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" +) + +// NodeSelectorRequirementApplyConfiguration represents an declarative configuration of the NodeSelectorRequirement type for use +// with apply. +type NodeSelectorRequirementApplyConfiguration struct { + Key *string `json:"key,omitempty"` + Operator *v1alpha1.NodeSelectorOperator `json:"operator,omitempty"` + Values []string `json:"values,omitempty"` +} + +// NodeSelectorRequirementApplyConfiguration constructs an declarative configuration of the NodeSelectorRequirement type for use with +// apply. +func NodeSelectorRequirement() *NodeSelectorRequirementApplyConfiguration { + return &NodeSelectorRequirementApplyConfiguration{} +} + +// WithKey sets the Key field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Key field is set to the value of the last call. +func (b *NodeSelectorRequirementApplyConfiguration) WithKey(value string) *NodeSelectorRequirementApplyConfiguration { + b.Key = &value + return b +} + +// WithOperator sets the Operator field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Operator field is set to the value of the last call. +func (b *NodeSelectorRequirementApplyConfiguration) WithOperator(value v1alpha1.NodeSelectorOperator) *NodeSelectorRequirementApplyConfiguration { + b.Operator = &value + return b +} + +// WithValues adds the given value to the Values field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Values field. +func (b *NodeSelectorRequirementApplyConfiguration) WithValues(values ...string) *NodeSelectorRequirementApplyConfiguration { + for i := range values { + b.Values = append(b.Values, values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/nodeselectorterm.go b/client-go/applyconfigurations/core/v1alpha1/nodeselectorterm.go new file mode 100644 index 00000000..aa552526 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/nodeselectorterm.go @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// NodeSelectorTermApplyConfiguration represents an declarative configuration of the NodeSelectorTerm type for use +// with apply. +type NodeSelectorTermApplyConfiguration struct { + MatchExpressions []NodeSelectorRequirementApplyConfiguration `json:"matchExpressions,omitempty"` + MatchFields []NodeSelectorRequirementApplyConfiguration `json:"matchFields,omitempty"` +} + +// NodeSelectorTermApplyConfiguration constructs an declarative configuration of the NodeSelectorTerm type for use with +// apply. +func NodeSelectorTerm() *NodeSelectorTermApplyConfiguration { + return &NodeSelectorTermApplyConfiguration{} +} + +// WithMatchExpressions adds the given value to the MatchExpressions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the MatchExpressions field. +func (b *NodeSelectorTermApplyConfiguration) WithMatchExpressions(values ...*NodeSelectorRequirementApplyConfiguration) *NodeSelectorTermApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMatchExpressions") + } + b.MatchExpressions = append(b.MatchExpressions, *values[i]) + } + return b +} + +// WithMatchFields adds the given value to the MatchFields field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the MatchFields field. +func (b *NodeSelectorTermApplyConfiguration) WithMatchFields(values ...*NodeSelectorRequirementApplyConfiguration) *NodeSelectorTermApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMatchFields") + } + b.MatchFields = append(b.MatchFields, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/pciaddress.go b/client-go/applyconfigurations/core/v1alpha1/pciaddress.go new file mode 100644 index 00000000..96bc6d2c --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/pciaddress.go @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// PCIAddressApplyConfiguration represents an declarative configuration of the PCIAddress type for use +// with apply. +type PCIAddressApplyConfiguration struct { + Domain *string `json:"domain,omitempty"` + Bus *string `json:"bus,omitempty"` + Slot *string `json:"slot,omitempty"` + Function *string `json:"function,omitempty"` +} + +// PCIAddressApplyConfiguration constructs an declarative configuration of the PCIAddress type for use with +// apply. +func PCIAddress() *PCIAddressApplyConfiguration { + return &PCIAddressApplyConfiguration{} +} + +// WithDomain sets the Domain field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Domain field is set to the value of the last call. +func (b *PCIAddressApplyConfiguration) WithDomain(value string) *PCIAddressApplyConfiguration { + b.Domain = &value + return b +} + +// WithBus sets the Bus field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Bus field is set to the value of the last call. +func (b *PCIAddressApplyConfiguration) WithBus(value string) *PCIAddressApplyConfiguration { + b.Bus = &value + return b +} + +// WithSlot sets the Slot field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Slot field is set to the value of the last call. +func (b *PCIAddressApplyConfiguration) WithSlot(value string) *PCIAddressApplyConfiguration { + b.Slot = &value + return b +} + +// WithFunction sets the Function field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Function field is set to the value of the last call. +func (b *PCIAddressApplyConfiguration) WithFunction(value string) *PCIAddressApplyConfiguration { + b.Function = &value + return b +} diff --git a/client-go/applyconfigurations/core/v1alpha1/topologyspreadconstraint.go b/client-go/applyconfigurations/core/v1alpha1/topologyspreadconstraint.go new file mode 100644 index 00000000..27c28af6 --- /dev/null +++ b/client-go/applyconfigurations/core/v1alpha1/topologyspreadconstraint.go @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" +) + +// TopologySpreadConstraintApplyConfiguration represents an declarative configuration of the TopologySpreadConstraint type for use +// with apply. +type TopologySpreadConstraintApplyConfiguration struct { + MaxSkew *int32 `json:"maxSkew,omitempty"` + TopologyKey *string `json:"topologyKey,omitempty"` + WhenUnsatisfiable *v1alpha1.UnsatisfiableConstraintAction `json:"whenUnsatisfiable,omitempty"` + LabelSelector *v1.LabelSelectorApplyConfiguration `json:"labelSelector,omitempty"` +} + +// TopologySpreadConstraintApplyConfiguration constructs an declarative configuration of the TopologySpreadConstraint type for use with +// apply. +func TopologySpreadConstraint() *TopologySpreadConstraintApplyConfiguration { + return &TopologySpreadConstraintApplyConfiguration{} +} + +// WithMaxSkew sets the MaxSkew field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MaxSkew field is set to the value of the last call. +func (b *TopologySpreadConstraintApplyConfiguration) WithMaxSkew(value int32) *TopologySpreadConstraintApplyConfiguration { + b.MaxSkew = &value + return b +} + +// WithTopologyKey sets the TopologyKey field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TopologyKey field is set to the value of the last call. +func (b *TopologySpreadConstraintApplyConfiguration) WithTopologyKey(value string) *TopologySpreadConstraintApplyConfiguration { + b.TopologyKey = &value + return b +} + +// WithWhenUnsatisfiable sets the WhenUnsatisfiable field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the WhenUnsatisfiable field is set to the value of the last call. +func (b *TopologySpreadConstraintApplyConfiguration) WithWhenUnsatisfiable(value v1alpha1.UnsatisfiableConstraintAction) *TopologySpreadConstraintApplyConfiguration { + b.WhenUnsatisfiable = &value + return b +} + +// WithLabelSelector sets the LabelSelector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LabelSelector field is set to the value of the last call. +func (b *TopologySpreadConstraintApplyConfiguration) WithLabelSelector(value *v1.LabelSelectorApplyConfiguration) *TopologySpreadConstraintApplyConfiguration { + b.LabelSelector = value + return b +} diff --git a/client-go/applyconfigurations/internal/internal.go b/client-go/applyconfigurations/internal/internal.go new file mode 100644 index 00000000..83a4887f --- /dev/null +++ b/client-go/applyconfigurations/internal/internal.go @@ -0,0 +1,1135 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Affinity + map: + fields: + - name: instanceAntiAffinity + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceAntiAffinity + - name: nodeAffinity + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeAffinity +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSet + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSetSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSetStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSetSpec + map: + fields: + - name: nodeSelector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + - name: template + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceTemplate + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.DaemonSetStatus + map: + fields: + - name: collisionCount + type: + scalar: numeric +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IP + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddress + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddressSpec + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddressClaimRef + map: + fields: + - name: group + type: + scalar: string + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: resource + type: + scalar: string + - name: uid + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddressSpec + map: + fields: + - name: claimRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPAddressClaimRef + default: {} + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPClaimRef + map: + fields: + - name: group + type: + scalar: string + - name: name + type: + scalar: string + - name: resource + type: + scalar: string + - name: uid + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPSpec + map: + fields: + - name: claimRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPClaimRef + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: ipFamily + type: + scalar: string + - name: type + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.IPStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Instance + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceAffinityTerm + map: + fields: + - name: labelSelector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + - name: topologyKey + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceAntiAffinity + map: + fields: + - name: requiredDuringSchedulingIgnoredDuringExecution + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceAffinityTerm + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceSpec + map: + fields: + - name: affinity + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Affinity + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic + - name: loadBalancerPorts + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerPort + elementRelationship: atomic + - name: loadBalancerType + type: + scalar: string + default: "" + - name: networkRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: nodeRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + - name: topologySpreadConstraints + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.TopologySpreadConstraint + elementRelationship: atomic + - name: type + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceStatus + map: + fields: + - name: collisionCount + type: + scalar: numeric + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceTemplate + map: + fields: + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceSpec + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancer + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerDestination + map: + fields: + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: targetRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerTargetRef +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerIP + map: + fields: + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: ipFamily + type: + scalar: string + - name: name + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerPort + map: + fields: + - name: endPort + type: + scalar: numeric + - name: port + type: + scalar: numeric + default: 0 + - name: protocol + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerRouting + map: + fields: + - name: apiVersion + type: + scalar: string + - name: destinations + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerDestination + elementRelationship: atomic + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerSpec + map: + fields: + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerIP + elementRelationship: associative + keys: + - name + - name: networkRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: nodeSelector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + - name: ports + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerPort + elementRelationship: atomic + - name: template + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.InstanceTemplate + default: {} + - name: type + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerStatus + map: + fields: + - name: collisionCount + type: + scalar: numeric + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.LoadBalancerTargetRef + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: nodeRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: uid + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGateway + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewaySpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscaler + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscalerSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscalerStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscalerSpec + map: + fields: + - name: maxPublicIPs + type: + scalar: numeric + - name: minPublicIPs + type: + scalar: numeric + - name: natGatewayRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayAutoscalerStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayIP + map: + fields: + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: name + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewaySpec + map: + fields: + - name: ipFamily + type: + scalar: string + default: "" + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayIP + elementRelationship: associative + keys: + - name + - name: networkRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: portsPerNetworkInterface + type: + scalar: numeric + default: 0 +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATGatewayStatus + map: + fields: + - name: requestedNATIPs + type: + scalar: numeric + - name: usedNATIPs + type: + scalar: numeric +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATIP + map: + fields: + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: sections + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATIPSection + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATIPSection + map: + fields: + - name: endPort + type: + scalar: numeric + default: 0 + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: port + type: + scalar: numeric + default: 0 + - name: targetRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATTableIPTargetRef +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATTable + map: + fields: + - name: apiVersion + type: + scalar: string + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATIP + elementRelationship: atomic + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NATTableIPTargetRef + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: nodeRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: uid + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Network + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkID + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkIDSpec + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkIDClaimRef + map: + fields: + - name: group + type: + scalar: string + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: resource + type: + scalar: string + - name: uid + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkIDSpec + map: + fields: + - name: claimRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkIDClaimRef + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterface + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceNAT + map: + fields: + - name: claimRef + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceNATClaimRef + default: {} + - name: ipFamily + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceNATClaimRef + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: uid + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfacePublicIP + map: + fields: + - name: ip + type: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + default: {} + - name: ipFamily + type: + scalar: string + - name: name + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceSpec + map: + fields: + - name: ips + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic + - name: natGateways + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceNAT + elementRelationship: atomic + - name: networkRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: nodeRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference + default: {} + - name: prefixes + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IPPrefix + elementRelationship: atomic + - name: publicIPs + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfacePublicIP + elementRelationship: associative + keys: + - name +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkInterfaceStatus + map: + fields: + - name: natIPs + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic + - name: pciAddress + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.PCIAddress + - name: prefixes + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IPPrefix + elementRelationship: atomic + - name: publicIPs + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + elementRelationship: atomic + - name: state + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkSpec + map: + fields: + - name: id + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NetworkStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.Node + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSpec + default: {} + - name: status + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeStatus + default: {} +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeAffinity + map: + fields: + - name: requiredDuringSchedulingIgnoredDuringExecution + type: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelector +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelector + map: + fields: + - name: nodeSelectorTerms + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelectorTerm + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelectorRequirement + map: + fields: + - name: key + type: + scalar: string + default: "" + - name: operator + type: + scalar: string + default: "" + - name: values + type: + list: + elementType: + scalar: string + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelectorTerm + map: + fields: + - name: matchExpressions + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelectorRequirement + elementRelationship: atomic + - name: matchFields + type: + list: + elementType: + namedType: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSelectorRequirement + elementRelationship: atomic +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeSpec + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.NodeStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.PCIAddress + map: + fields: + - name: bus + type: + scalar: string + - name: domain + type: + scalar: string + - name: function + type: + scalar: string + - name: slot + type: + scalar: string +- name: com.github.onmetal.onmetal-api-net.api.core.v1alpha1.TopologySpreadConstraint + map: + fields: + - name: labelSelector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + - name: maxSkew + type: + scalar: numeric + default: 0 + - name: topologyKey + type: + scalar: string + default: "" + - name: whenUnsatisfiable + type: + scalar: string + default: "" +- name: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IP + scalar: untyped +- name: com.github.onmetal.onmetal-api-net.apimachinery.api.net.IPPrefix + scalar: untyped +- name: io.k8s.api.core.v1.LocalObjectReference + map: + fields: + - name: name + type: + scalar: string + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + map: + fields: + - name: matchExpressions + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement + elementRelationship: atomic + - name: matchLabels + type: + map: + elementType: + scalar: string + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement + map: + fields: + - name: key + type: + scalar: string + default: "" + - name: operator + type: + scalar: string + default: "" + - name: values + type: + list: + elementType: + scalar: string + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + map: + fields: + - name: apiVersion + type: + scalar: string + - name: fieldsType + type: + scalar: string + - name: fieldsV1 + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + - name: manager + type: + scalar: string + - name: operation + type: + scalar: string + - name: subresource + type: + scalar: string + - name: time + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: creationTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + default: {} + - name: deletionGracePeriodSeconds + type: + scalar: numeric + - name: deletionTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: finalizers + type: + list: + elementType: + scalar: string + elementRelationship: associative + - name: generateName + type: + scalar: string + - name: generation + type: + scalar: numeric + - name: labels + type: + map: + elementType: + scalar: string + - name: managedFields + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + elementRelationship: atomic + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: ownerReferences + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + elementRelationship: associative + keys: + - uid + - name: resourceVersion + type: + scalar: string + - name: selfLink + type: + scalar: string + - name: uid + type: + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: blockOwnerDeletion + type: + scalar: boolean + - name: controller + type: + scalar: boolean + - name: kind + type: + scalar: string + default: "" + - name: name + type: + scalar: string + default: "" + - name: uid + type: + scalar: string + default: "" + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Time + scalar: untyped +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/client-go/applyconfigurations/meta/v1/labelselector.go b/client-go/applyconfigurations/meta/v1/labelselector.go new file mode 100644 index 00000000..d430cd16 --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/labelselector.go @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// LabelSelectorApplyConfiguration represents an declarative configuration of the LabelSelector type for use +// with apply. +type LabelSelectorApplyConfiguration struct { + MatchLabels map[string]string `json:"matchLabels,omitempty"` + MatchExpressions []LabelSelectorRequirementApplyConfiguration `json:"matchExpressions,omitempty"` +} + +// LabelSelectorApplyConfiguration constructs an declarative configuration of the LabelSelector type for use with +// apply. +func LabelSelector() *LabelSelectorApplyConfiguration { + return &LabelSelectorApplyConfiguration{} +} + +// WithMatchLabels puts the entries into the MatchLabels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the MatchLabels field, +// overwriting an existing map entries in MatchLabels field with the same key. +func (b *LabelSelectorApplyConfiguration) WithMatchLabels(entries map[string]string) *LabelSelectorApplyConfiguration { + if b.MatchLabels == nil && len(entries) > 0 { + b.MatchLabels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.MatchLabels[k] = v + } + return b +} + +// WithMatchExpressions adds the given value to the MatchExpressions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the MatchExpressions field. +func (b *LabelSelectorApplyConfiguration) WithMatchExpressions(values ...*LabelSelectorRequirementApplyConfiguration) *LabelSelectorApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMatchExpressions") + } + b.MatchExpressions = append(b.MatchExpressions, *values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/meta/v1/labelselectorrequirement.go b/client-go/applyconfigurations/meta/v1/labelselectorrequirement.go new file mode 100644 index 00000000..84f30394 --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/labelselectorrequirement.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// LabelSelectorRequirementApplyConfiguration represents an declarative configuration of the LabelSelectorRequirement type for use +// with apply. +type LabelSelectorRequirementApplyConfiguration struct { + Key *string `json:"key,omitempty"` + Operator *v1.LabelSelectorOperator `json:"operator,omitempty"` + Values []string `json:"values,omitempty"` +} + +// LabelSelectorRequirementApplyConfiguration constructs an declarative configuration of the LabelSelectorRequirement type for use with +// apply. +func LabelSelectorRequirement() *LabelSelectorRequirementApplyConfiguration { + return &LabelSelectorRequirementApplyConfiguration{} +} + +// WithKey sets the Key field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Key field is set to the value of the last call. +func (b *LabelSelectorRequirementApplyConfiguration) WithKey(value string) *LabelSelectorRequirementApplyConfiguration { + b.Key = &value + return b +} + +// WithOperator sets the Operator field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Operator field is set to the value of the last call. +func (b *LabelSelectorRequirementApplyConfiguration) WithOperator(value v1.LabelSelectorOperator) *LabelSelectorRequirementApplyConfiguration { + b.Operator = &value + return b +} + +// WithValues adds the given value to the Values field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Values field. +func (b *LabelSelectorRequirementApplyConfiguration) WithValues(values ...string) *LabelSelectorRequirementApplyConfiguration { + for i := range values { + b.Values = append(b.Values, values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/meta/v1/managedfieldsentry.go b/client-go/applyconfigurations/meta/v1/managedfieldsentry.go new file mode 100644 index 00000000..0255581a --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/managedfieldsentry.go @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ManagedFieldsEntryApplyConfiguration represents an declarative configuration of the ManagedFieldsEntry type for use +// with apply. +type ManagedFieldsEntryApplyConfiguration struct { + Manager *string `json:"manager,omitempty"` + Operation *v1.ManagedFieldsOperationType `json:"operation,omitempty"` + APIVersion *string `json:"apiVersion,omitempty"` + Time *v1.Time `json:"time,omitempty"` + FieldsType *string `json:"fieldsType,omitempty"` + FieldsV1 *v1.FieldsV1 `json:"fieldsV1,omitempty"` + Subresource *string `json:"subresource,omitempty"` +} + +// ManagedFieldsEntryApplyConfiguration constructs an declarative configuration of the ManagedFieldsEntry type for use with +// apply. +func ManagedFieldsEntry() *ManagedFieldsEntryApplyConfiguration { + return &ManagedFieldsEntryApplyConfiguration{} +} + +// WithManager sets the Manager field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Manager field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithManager(value string) *ManagedFieldsEntryApplyConfiguration { + b.Manager = &value + return b +} + +// WithOperation sets the Operation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Operation field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithOperation(value v1.ManagedFieldsOperationType) *ManagedFieldsEntryApplyConfiguration { + b.Operation = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithAPIVersion(value string) *ManagedFieldsEntryApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithTime sets the Time field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Time field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithTime(value v1.Time) *ManagedFieldsEntryApplyConfiguration { + b.Time = &value + return b +} + +// WithFieldsType sets the FieldsType field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FieldsType field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithFieldsType(value string) *ManagedFieldsEntryApplyConfiguration { + b.FieldsType = &value + return b +} + +// WithFieldsV1 sets the FieldsV1 field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FieldsV1 field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithFieldsV1(value v1.FieldsV1) *ManagedFieldsEntryApplyConfiguration { + b.FieldsV1 = &value + return b +} + +// WithSubresource sets the Subresource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Subresource field is set to the value of the last call. +func (b *ManagedFieldsEntryApplyConfiguration) WithSubresource(value string) *ManagedFieldsEntryApplyConfiguration { + b.Subresource = &value + return b +} diff --git a/client-go/applyconfigurations/meta/v1/objectmeta.go b/client-go/applyconfigurations/meta/v1/objectmeta.go new file mode 100644 index 00000000..774e5d7b --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/objectmeta.go @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" +) + +// ObjectMetaApplyConfiguration represents an declarative configuration of the ObjectMeta type for use +// with apply. +type ObjectMetaApplyConfiguration struct { + Name *string `json:"name,omitempty"` + GenerateName *string `json:"generateName,omitempty"` + Namespace *string `json:"namespace,omitempty"` + UID *types.UID `json:"uid,omitempty"` + ResourceVersion *string `json:"resourceVersion,omitempty"` + Generation *int64 `json:"generation,omitempty"` + CreationTimestamp *v1.Time `json:"creationTimestamp,omitempty"` + DeletionTimestamp *v1.Time `json:"deletionTimestamp,omitempty"` + DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + OwnerReferences []OwnerReferenceApplyConfiguration `json:"ownerReferences,omitempty"` + Finalizers []string `json:"finalizers,omitempty"` +} + +// ObjectMetaApplyConfiguration constructs an declarative configuration of the ObjectMeta type for use with +// apply. +func ObjectMeta() *ObjectMetaApplyConfiguration { + return &ObjectMetaApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithName(value string) *ObjectMetaApplyConfiguration { + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithGenerateName(value string) *ObjectMetaApplyConfiguration { + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithNamespace(value string) *ObjectMetaApplyConfiguration { + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithUID(value types.UID) *ObjectMetaApplyConfiguration { + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithResourceVersion(value string) *ObjectMetaApplyConfiguration { + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithGeneration(value int64) *ObjectMetaApplyConfiguration { + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithCreationTimestamp(value v1.Time) *ObjectMetaApplyConfiguration { + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithDeletionTimestamp(value v1.Time) *ObjectMetaApplyConfiguration { + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ObjectMetaApplyConfiguration { + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ObjectMetaApplyConfiguration) WithLabels(entries map[string]string) *ObjectMetaApplyConfiguration { + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ObjectMetaApplyConfiguration) WithAnnotations(entries map[string]string) *ObjectMetaApplyConfiguration { + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ObjectMetaApplyConfiguration) WithOwnerReferences(values ...*OwnerReferenceApplyConfiguration) *ObjectMetaApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *ObjectMetaApplyConfiguration) WithFinalizers(values ...string) *ObjectMetaApplyConfiguration { + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} diff --git a/client-go/applyconfigurations/meta/v1/ownerreference.go b/client-go/applyconfigurations/meta/v1/ownerreference.go new file mode 100644 index 00000000..0059b555 --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/ownerreference.go @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + types "k8s.io/apimachinery/pkg/types" +) + +// OwnerReferenceApplyConfiguration represents an declarative configuration of the OwnerReference type for use +// with apply. +type OwnerReferenceApplyConfiguration struct { + APIVersion *string `json:"apiVersion,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + UID *types.UID `json:"uid,omitempty"` + Controller *bool `json:"controller,omitempty"` + BlockOwnerDeletion *bool `json:"blockOwnerDeletion,omitempty"` +} + +// OwnerReferenceApplyConfiguration constructs an declarative configuration of the OwnerReference type for use with +// apply. +func OwnerReference() *OwnerReferenceApplyConfiguration { + return &OwnerReferenceApplyConfiguration{} +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithAPIVersion(value string) *OwnerReferenceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithKind(value string) *OwnerReferenceApplyConfiguration { + b.Kind = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithName(value string) *OwnerReferenceApplyConfiguration { + b.Name = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithUID(value types.UID) *OwnerReferenceApplyConfiguration { + b.UID = &value + return b +} + +// WithController sets the Controller field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Controller field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithController(value bool) *OwnerReferenceApplyConfiguration { + b.Controller = &value + return b +} + +// WithBlockOwnerDeletion sets the BlockOwnerDeletion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the BlockOwnerDeletion field is set to the value of the last call. +func (b *OwnerReferenceApplyConfiguration) WithBlockOwnerDeletion(value bool) *OwnerReferenceApplyConfiguration { + b.BlockOwnerDeletion = &value + return b +} diff --git a/client-go/applyconfigurations/meta/v1/typemeta.go b/client-go/applyconfigurations/meta/v1/typemeta.go new file mode 100644 index 00000000..63743763 --- /dev/null +++ b/client-go/applyconfigurations/meta/v1/typemeta.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// TypeMetaApplyConfiguration represents an declarative configuration of the TypeMeta type for use +// with apply. +type TypeMetaApplyConfiguration struct { + Kind *string `json:"kind,omitempty"` + APIVersion *string `json:"apiVersion,omitempty"` +} + +// TypeMetaApplyConfiguration constructs an declarative configuration of the TypeMeta type for use with +// apply. +func TypeMeta() *TypeMetaApplyConfiguration { + return &TypeMetaApplyConfiguration{} +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *TypeMetaApplyConfiguration) WithKind(value string) *TypeMetaApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *TypeMetaApplyConfiguration) WithAPIVersion(value string) *TypeMetaApplyConfiguration { + b.APIVersion = &value + return b +} diff --git a/client-go/applyconfigurations/utils.go b/client-go/applyconfigurations/utils.go new file mode 100644 index 00000000..1cbafae2 --- /dev/null +++ b/client-go/applyconfigurations/utils.go @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 applyconfiguration-gen. DO NOT EDIT. + +package applyconfigurations + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + metav1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=core.apinet.api.onmetal.de, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("Affinity"): + return &corev1alpha1.AffinityApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("DaemonSet"): + return &corev1alpha1.DaemonSetApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("DaemonSetSpec"): + return &corev1alpha1.DaemonSetSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("DaemonSetStatus"): + return &corev1alpha1.DaemonSetStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Instance"): + return &corev1alpha1.InstanceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstanceAffinityTerm"): + return &corev1alpha1.InstanceAffinityTermApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstanceAntiAffinity"): + return &corev1alpha1.InstanceAntiAffinityApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstanceSpec"): + return &corev1alpha1.InstanceSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstanceStatus"): + return &corev1alpha1.InstanceStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstanceTemplate"): + return &corev1alpha1.InstanceTemplateApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IP"): + return &corev1alpha1.IPApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IPAddress"): + return &corev1alpha1.IPAddressApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IPAddressClaimRef"): + return &corev1alpha1.IPAddressClaimRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IPAddressSpec"): + return &corev1alpha1.IPAddressSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IPClaimRef"): + return &corev1alpha1.IPClaimRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("IPSpec"): + return &corev1alpha1.IPSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancer"): + return &corev1alpha1.LoadBalancerApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerDestination"): + return &corev1alpha1.LoadBalancerDestinationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerIP"): + return &corev1alpha1.LoadBalancerIPApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerPort"): + return &corev1alpha1.LoadBalancerPortApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerRouting"): + return &corev1alpha1.LoadBalancerRoutingApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerSpec"): + return &corev1alpha1.LoadBalancerSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerStatus"): + return &corev1alpha1.LoadBalancerStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerTargetRef"): + return &corev1alpha1.LoadBalancerTargetRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGateway"): + return &corev1alpha1.NATGatewayApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGatewayAutoscaler"): + return &corev1alpha1.NATGatewayAutoscalerApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGatewayAutoscalerSpec"): + return &corev1alpha1.NATGatewayAutoscalerSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGatewayIP"): + return &corev1alpha1.NATGatewayIPApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGatewaySpec"): + return &corev1alpha1.NATGatewaySpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATGatewayStatus"): + return &corev1alpha1.NATGatewayStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATIP"): + return &corev1alpha1.NATIPApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATIPSection"): + return &corev1alpha1.NATIPSectionApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATTable"): + return &corev1alpha1.NATTableApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NATTableIPTargetRef"): + return &corev1alpha1.NATTableIPTargetRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Network"): + return &corev1alpha1.NetworkApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkID"): + return &corev1alpha1.NetworkIDApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkIDClaimRef"): + return &corev1alpha1.NetworkIDClaimRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkIDSpec"): + return &corev1alpha1.NetworkIDSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterface"): + return &corev1alpha1.NetworkInterfaceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceNAT"): + return &corev1alpha1.NetworkInterfaceNATApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceNATClaimRef"): + return &corev1alpha1.NetworkInterfaceNATClaimRefApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfacePublicIP"): + return &corev1alpha1.NetworkInterfacePublicIPApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceSpec"): + return &corev1alpha1.NetworkInterfaceSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceStatus"): + return &corev1alpha1.NetworkInterfaceStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkSpec"): + return &corev1alpha1.NetworkSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Node"): + return &corev1alpha1.NodeApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NodeAffinity"): + return &corev1alpha1.NodeAffinityApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NodeSelector"): + return &corev1alpha1.NodeSelectorApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NodeSelectorRequirement"): + return &corev1alpha1.NodeSelectorRequirementApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NodeSelectorTerm"): + return &corev1alpha1.NodeSelectorTermApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PCIAddress"): + return &corev1alpha1.PCIAddressApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("TopologySpreadConstraint"): + return &corev1alpha1.TopologySpreadConstraintApplyConfiguration{} + + // Group=meta.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithKind("LabelSelector"): + return &metav1.LabelSelectorApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("LabelSelectorRequirement"): + return &metav1.LabelSelectorRequirementApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ManagedFieldsEntry"): + return &metav1.ManagedFieldsEntryApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ObjectMeta"): + return &metav1.ObjectMetaApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("OwnerReference"): + return &metav1.OwnerReferenceApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("TypeMeta"): + return &metav1.TypeMetaApplyConfiguration{} + + } + return nil +} diff --git a/client-go/informers/core/interface.go b/client-go/informers/core/interface.go new file mode 100644 index 00000000..2d5bba59 --- /dev/null +++ b/client-go/informers/core/interface.go @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package core + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/informers/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/client-go/informers/core/v1alpha1/daemonset.go b/client-go/informers/core/v1alpha1/daemonset.go new file mode 100644 index 00000000..cf292dbc --- /dev/null +++ b/client-go/informers/core/v1alpha1/daemonset.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// DaemonSetInformer provides access to a shared informer and lister for +// DaemonSets. +type DaemonSetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.DaemonSetLister +} + +type daemonSetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewDaemonSetInformer constructs a new informer for DaemonSet type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewDaemonSetInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredDaemonSetInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredDaemonSetInformer constructs a new informer for DaemonSet type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredDaemonSetInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().DaemonSets(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().DaemonSets(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.DaemonSet{}, + resyncPeriod, + indexers, + ) +} + +func (f *daemonSetInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredDaemonSetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *daemonSetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.DaemonSet{}, f.defaultInformer) +} + +func (f *daemonSetInformer) Lister() v1alpha1.DaemonSetLister { + return v1alpha1.NewDaemonSetLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/instance.go b/client-go/informers/core/v1alpha1/instance.go new file mode 100644 index 00000000..fb9454e8 --- /dev/null +++ b/client-go/informers/core/v1alpha1/instance.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// InstanceInformer provides access to a shared informer and lister for +// Instances. +type InstanceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.InstanceLister +} + +type instanceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewInstanceInformer constructs a new informer for Instance type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewInstanceInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredInstanceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredInstanceInformer constructs a new informer for Instance type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredInstanceInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Instances(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Instances(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.Instance{}, + resyncPeriod, + indexers, + ) +} + +func (f *instanceInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredInstanceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *instanceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.Instance{}, f.defaultInformer) +} + +func (f *instanceInformer) Lister() v1alpha1.InstanceLister { + return v1alpha1.NewInstanceLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/interface.go b/client-go/informers/core/v1alpha1/interface.go new file mode 100644 index 00000000..5bd97d13 --- /dev/null +++ b/client-go/informers/core/v1alpha1/interface.go @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // DaemonSets returns a DaemonSetInformer. + DaemonSets() DaemonSetInformer + // IPs returns a IPInformer. + IPs() IPInformer + // IPAddresses returns a IPAddressInformer. + IPAddresses() IPAddressInformer + // Instances returns a InstanceInformer. + Instances() InstanceInformer + // LoadBalancers returns a LoadBalancerInformer. + LoadBalancers() LoadBalancerInformer + // LoadBalancerRoutings returns a LoadBalancerRoutingInformer. + LoadBalancerRoutings() LoadBalancerRoutingInformer + // NATGateways returns a NATGatewayInformer. + NATGateways() NATGatewayInformer + // NATGatewayAutoscalers returns a NATGatewayAutoscalerInformer. + NATGatewayAutoscalers() NATGatewayAutoscalerInformer + // NATTables returns a NATTableInformer. + NATTables() NATTableInformer + // Networks returns a NetworkInformer. + Networks() NetworkInformer + // NetworkIDs returns a NetworkIDInformer. + NetworkIDs() NetworkIDInformer + // NetworkInterfaces returns a NetworkInterfaceInformer. + NetworkInterfaces() NetworkInterfaceInformer + // Nodes returns a NodeInformer. + Nodes() NodeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// DaemonSets returns a DaemonSetInformer. +func (v *version) DaemonSets() DaemonSetInformer { + return &daemonSetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// IPs returns a IPInformer. +func (v *version) IPs() IPInformer { + return &iPInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// IPAddresses returns a IPAddressInformer. +func (v *version) IPAddresses() IPAddressInformer { + return &iPAddressInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// Instances returns a InstanceInformer. +func (v *version) Instances() InstanceInformer { + return &instanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// LoadBalancers returns a LoadBalancerInformer. +func (v *version) LoadBalancers() LoadBalancerInformer { + return &loadBalancerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// LoadBalancerRoutings returns a LoadBalancerRoutingInformer. +func (v *version) LoadBalancerRoutings() LoadBalancerRoutingInformer { + return &loadBalancerRoutingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// NATGateways returns a NATGatewayInformer. +func (v *version) NATGateways() NATGatewayInformer { + return &nATGatewayInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// NATGatewayAutoscalers returns a NATGatewayAutoscalerInformer. +func (v *version) NATGatewayAutoscalers() NATGatewayAutoscalerInformer { + return &nATGatewayAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// NATTables returns a NATTableInformer. +func (v *version) NATTables() NATTableInformer { + return &nATTableInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Networks returns a NetworkInformer. +func (v *version) Networks() NetworkInformer { + return &networkInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// NetworkIDs returns a NetworkIDInformer. +func (v *version) NetworkIDs() NetworkIDInformer { + return &networkIDInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// NetworkInterfaces returns a NetworkInterfaceInformer. +func (v *version) NetworkInterfaces() NetworkInterfaceInformer { + return &networkInterfaceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Nodes returns a NodeInformer. +func (v *version) Nodes() NodeInformer { + return &nodeInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/client-go/informers/core/v1alpha1/ip.go b/client-go/informers/core/v1alpha1/ip.go new file mode 100644 index 00000000..ff7ec42a --- /dev/null +++ b/client-go/informers/core/v1alpha1/ip.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// IPInformer provides access to a shared informer and lister for +// IPs. +type IPInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IPLister +} + +type iPInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIPInformer constructs a new informer for IP type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewIPInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIPInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIPInformer constructs a new informer for IP type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredIPInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().IPs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().IPs(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.IP{}, + resyncPeriod, + indexers, + ) +} + +func (f *iPInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIPInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *iPInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.IP{}, f.defaultInformer) +} + +func (f *iPInformer) Lister() v1alpha1.IPLister { + return v1alpha1.NewIPLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/ipaddress.go b/client-go/informers/core/v1alpha1/ipaddress.go new file mode 100644 index 00000000..94a71f15 --- /dev/null +++ b/client-go/informers/core/v1alpha1/ipaddress.go @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// IPAddressInformer provides access to a shared informer and lister for +// IPAddresses. +type IPAddressInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IPAddressLister +} + +type iPAddressInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewIPAddressInformer constructs a new informer for IPAddress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewIPAddressInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIPAddressInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredIPAddressInformer constructs a new informer for IPAddress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredIPAddressInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().IPAddresses().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().IPAddresses().Watch(context.TODO(), options) + }, + }, + &corev1alpha1.IPAddress{}, + resyncPeriod, + indexers, + ) +} + +func (f *iPAddressInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIPAddressInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *iPAddressInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.IPAddress{}, f.defaultInformer) +} + +func (f *iPAddressInformer) Lister() v1alpha1.IPAddressLister { + return v1alpha1.NewIPAddressLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/loadbalancer.go b/client-go/informers/core/v1alpha1/loadbalancer.go new file mode 100644 index 00000000..a73472ea --- /dev/null +++ b/client-go/informers/core/v1alpha1/loadbalancer.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// LoadBalancerInformer provides access to a shared informer and lister for +// LoadBalancers. +type LoadBalancerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.LoadBalancerLister +} + +type loadBalancerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewLoadBalancerInformer constructs a new informer for LoadBalancer type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewLoadBalancerInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredLoadBalancerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredLoadBalancerInformer constructs a new informer for LoadBalancer type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredLoadBalancerInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().LoadBalancers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().LoadBalancers(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.LoadBalancer{}, + resyncPeriod, + indexers, + ) +} + +func (f *loadBalancerInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredLoadBalancerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *loadBalancerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.LoadBalancer{}, f.defaultInformer) +} + +func (f *loadBalancerInformer) Lister() v1alpha1.LoadBalancerLister { + return v1alpha1.NewLoadBalancerLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/loadbalancerrouting.go b/client-go/informers/core/v1alpha1/loadbalancerrouting.go new file mode 100644 index 00000000..e57c9eab --- /dev/null +++ b/client-go/informers/core/v1alpha1/loadbalancerrouting.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// LoadBalancerRoutingInformer provides access to a shared informer and lister for +// LoadBalancerRoutings. +type LoadBalancerRoutingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.LoadBalancerRoutingLister +} + +type loadBalancerRoutingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewLoadBalancerRoutingInformer constructs a new informer for LoadBalancerRouting type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewLoadBalancerRoutingInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredLoadBalancerRoutingInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredLoadBalancerRoutingInformer constructs a new informer for LoadBalancerRouting type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredLoadBalancerRoutingInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().LoadBalancerRoutings(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().LoadBalancerRoutings(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.LoadBalancerRouting{}, + resyncPeriod, + indexers, + ) +} + +func (f *loadBalancerRoutingInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredLoadBalancerRoutingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *loadBalancerRoutingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.LoadBalancerRouting{}, f.defaultInformer) +} + +func (f *loadBalancerRoutingInformer) Lister() v1alpha1.LoadBalancerRoutingLister { + return v1alpha1.NewLoadBalancerRoutingLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/natgateway.go b/client-go/informers/core/v1alpha1/natgateway.go new file mode 100644 index 00000000..561bfda6 --- /dev/null +++ b/client-go/informers/core/v1alpha1/natgateway.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NATGatewayInformer provides access to a shared informer and lister for +// NATGateways. +type NATGatewayInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NATGatewayLister +} + +type nATGatewayInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewNATGatewayInformer constructs a new informer for NATGateway type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNATGatewayInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNATGatewayInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredNATGatewayInformer constructs a new informer for NATGateway type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNATGatewayInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATGateways(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATGateways(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.NATGateway{}, + resyncPeriod, + indexers, + ) +} + +func (f *nATGatewayInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNATGatewayInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nATGatewayInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.NATGateway{}, f.defaultInformer) +} + +func (f *nATGatewayInformer) Lister() v1alpha1.NATGatewayLister { + return v1alpha1.NewNATGatewayLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/natgatewayautoscaler.go b/client-go/informers/core/v1alpha1/natgatewayautoscaler.go new file mode 100644 index 00000000..88c7ad86 --- /dev/null +++ b/client-go/informers/core/v1alpha1/natgatewayautoscaler.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NATGatewayAutoscalerInformer provides access to a shared informer and lister for +// NATGatewayAutoscalers. +type NATGatewayAutoscalerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NATGatewayAutoscalerLister +} + +type nATGatewayAutoscalerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewNATGatewayAutoscalerInformer constructs a new informer for NATGatewayAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNATGatewayAutoscalerInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNATGatewayAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredNATGatewayAutoscalerInformer constructs a new informer for NATGatewayAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNATGatewayAutoscalerInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATGatewayAutoscalers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATGatewayAutoscalers(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.NATGatewayAutoscaler{}, + resyncPeriod, + indexers, + ) +} + +func (f *nATGatewayAutoscalerInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNATGatewayAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nATGatewayAutoscalerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.NATGatewayAutoscaler{}, f.defaultInformer) +} + +func (f *nATGatewayAutoscalerInformer) Lister() v1alpha1.NATGatewayAutoscalerLister { + return v1alpha1.NewNATGatewayAutoscalerLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/nattable.go b/client-go/informers/core/v1alpha1/nattable.go new file mode 100644 index 00000000..1cce864f --- /dev/null +++ b/client-go/informers/core/v1alpha1/nattable.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NATTableInformer provides access to a shared informer and lister for +// NATTables. +type NATTableInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NATTableLister +} + +type nATTableInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewNATTableInformer constructs a new informer for NATTable type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNATTableInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNATTableInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredNATTableInformer constructs a new informer for NATTable type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNATTableInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATTables(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NATTables(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.NATTable{}, + resyncPeriod, + indexers, + ) +} + +func (f *nATTableInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNATTableInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nATTableInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.NATTable{}, f.defaultInformer) +} + +func (f *nATTableInformer) Lister() v1alpha1.NATTableLister { + return v1alpha1.NewNATTableLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/network.go b/client-go/informers/core/v1alpha1/network.go new file mode 100644 index 00000000..5c8c1f71 --- /dev/null +++ b/client-go/informers/core/v1alpha1/network.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NetworkInformer provides access to a shared informer and lister for +// Networks. +type NetworkInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NetworkLister +} + +type networkInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewNetworkInformer constructs a new informer for Network type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNetworkInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNetworkInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredNetworkInformer constructs a new informer for Network type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNetworkInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Networks(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Networks(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.Network{}, + resyncPeriod, + indexers, + ) +} + +func (f *networkInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNetworkInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *networkInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.Network{}, f.defaultInformer) +} + +func (f *networkInformer) Lister() v1alpha1.NetworkLister { + return v1alpha1.NewNetworkLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/networkid.go b/client-go/informers/core/v1alpha1/networkid.go new file mode 100644 index 00000000..928acde7 --- /dev/null +++ b/client-go/informers/core/v1alpha1/networkid.go @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NetworkIDInformer provides access to a shared informer and lister for +// NetworkIDs. +type NetworkIDInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NetworkIDLister +} + +type networkIDInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNetworkIDInformer constructs a new informer for NetworkID type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNetworkIDInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNetworkIDInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNetworkIDInformer constructs a new informer for NetworkID type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNetworkIDInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NetworkIDs().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NetworkIDs().Watch(context.TODO(), options) + }, + }, + &corev1alpha1.NetworkID{}, + resyncPeriod, + indexers, + ) +} + +func (f *networkIDInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNetworkIDInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *networkIDInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.NetworkID{}, f.defaultInformer) +} + +func (f *networkIDInformer) Lister() v1alpha1.NetworkIDLister { + return v1alpha1.NewNetworkIDLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/networkinterface.go b/client-go/informers/core/v1alpha1/networkinterface.go new file mode 100644 index 00000000..64f87e92 --- /dev/null +++ b/client-go/informers/core/v1alpha1/networkinterface.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NetworkInterfaceInformer provides access to a shared informer and lister for +// NetworkInterfaces. +type NetworkInterfaceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NetworkInterfaceLister +} + +type networkInterfaceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewNetworkInterfaceInformer constructs a new informer for NetworkInterface type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNetworkInterfaceInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNetworkInterfaceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredNetworkInterfaceInformer constructs a new informer for NetworkInterface type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNetworkInterfaceInformer(client onmetalapinet.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NetworkInterfaces(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().NetworkInterfaces(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.NetworkInterface{}, + resyncPeriod, + indexers, + ) +} + +func (f *networkInterfaceInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNetworkInterfaceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *networkInterfaceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.NetworkInterface{}, f.defaultInformer) +} + +func (f *networkInterfaceInformer) Lister() v1alpha1.NetworkInterfaceLister { + return v1alpha1.NewNetworkInterfaceLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/core/v1alpha1/node.go b/client-go/informers/core/v1alpha1/node.go new file mode 100644 index 00000000..9bb448f4 --- /dev/null +++ b/client-go/informers/core/v1alpha1/node.go @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// NodeInformer provides access to a shared informer and lister for +// Nodes. +type NodeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NodeLister +} + +type nodeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNodeInformer constructs a new informer for Node type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNodeInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNodeInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNodeInformer constructs a new informer for Node type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNodeInformer(client onmetalapinet.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Nodes().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().Nodes().Watch(context.TODO(), options) + }, + }, + &corev1alpha1.Node{}, + resyncPeriod, + indexers, + ) +} + +func (f *nodeInformer) defaultInformer(client onmetalapinet.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNodeInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nodeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.Node{}, f.defaultInformer) +} + +func (f *nodeInformer) Lister() v1alpha1.NodeLister { + return v1alpha1.NewNodeLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/factory.go b/client-go/informers/factory.go new file mode 100644 index 00000000..e39d3258 --- /dev/null +++ b/client-go/informers/factory.go @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package informers + +import ( + reflect "reflect" + sync "sync" + time "time" + + core "github.com/onmetal/onmetal-api-net/client-go/informers/core" + internalinterfaces "github.com/onmetal/onmetal-api-net/client-go/informers/internalinterfaces" + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client onmetalapinet.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client onmetalapinet.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client onmetalapinet.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client onmetalapinet.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InternalInformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Core() core.Interface +} + +func (f *sharedInformerFactory) Core() core.Interface { + return core.New(f, f.namespace, f.tweakListOptions) +} diff --git a/client-go/informers/generic.go b/client-go/informers/generic.go new file mode 100644 index 00000000..7e0220a5 --- /dev/null +++ b/client-go/informers/generic.go @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package informers + +import ( + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=core.apinet.api.onmetal.de, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("daemonsets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().DaemonSets().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("ips"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().IPs().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("ipaddresses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().IPAddresses().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("instances"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().Instances().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("loadbalancers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().LoadBalancers().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("loadbalancerroutings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().LoadBalancerRoutings().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("natgateways"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().NATGateways().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("natgatewayautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().NATGatewayAutoscalers().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("nattables"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().NATTables().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("networks"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().Networks().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("networkids"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().NetworkIDs().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("networkinterfaces"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().NetworkInterfaces().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("nodes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().Nodes().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/client-go/informers/internalinterfaces/factory_interfaces.go b/client-go/informers/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000..8b20afe5 --- /dev/null +++ b/client-go/informers/internalinterfaces/factory_interfaces.go @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + onmetalapinet "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes onmetalapinet.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(onmetalapinet.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/client-go/listers/core/v1alpha1/daemonset.go b/client-go/listers/core/v1alpha1/daemonset.go new file mode 100644 index 00000000..06aba9ba --- /dev/null +++ b/client-go/listers/core/v1alpha1/daemonset.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// DaemonSetLister helps list DaemonSets. +// All objects returned here must be treated as read-only. +type DaemonSetLister interface { + // List lists all DaemonSets in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.DaemonSet, err error) + // DaemonSets returns an object that can list and get DaemonSets. + DaemonSets(namespace string) DaemonSetNamespaceLister + DaemonSetListerExpansion +} + +// daemonSetLister implements the DaemonSetLister interface. +type daemonSetLister struct { + indexer cache.Indexer +} + +// NewDaemonSetLister returns a new DaemonSetLister. +func NewDaemonSetLister(indexer cache.Indexer) DaemonSetLister { + return &daemonSetLister{indexer: indexer} +} + +// List lists all DaemonSets in the indexer. +func (s *daemonSetLister) List(selector labels.Selector) (ret []*v1alpha1.DaemonSet, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.DaemonSet)) + }) + return ret, err +} + +// DaemonSets returns an object that can list and get DaemonSets. +func (s *daemonSetLister) DaemonSets(namespace string) DaemonSetNamespaceLister { + return daemonSetNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// DaemonSetNamespaceLister helps list and get DaemonSets. +// All objects returned here must be treated as read-only. +type DaemonSetNamespaceLister interface { + // List lists all DaemonSets in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.DaemonSet, err error) + // Get retrieves the DaemonSet from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.DaemonSet, error) + DaemonSetNamespaceListerExpansion +} + +// daemonSetNamespaceLister implements the DaemonSetNamespaceLister +// interface. +type daemonSetNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all DaemonSets in the indexer for a given namespace. +func (s daemonSetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaemonSet, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.DaemonSet)) + }) + return ret, err +} + +// Get retrieves the DaemonSet from the indexer for a given namespace and name. +func (s daemonSetNamespaceLister) Get(name string) (*v1alpha1.DaemonSet, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("daemonset"), name) + } + return obj.(*v1alpha1.DaemonSet), nil +} diff --git a/client-go/listers/core/v1alpha1/expansion_generated.go b/client-go/listers/core/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..7e0af074 --- /dev/null +++ b/client-go/listers/core/v1alpha1/expansion_generated.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// DaemonSetListerExpansion allows custom methods to be added to +// DaemonSetLister. +type DaemonSetListerExpansion interface{} + +// DaemonSetNamespaceListerExpansion allows custom methods to be added to +// DaemonSetNamespaceLister. +type DaemonSetNamespaceListerExpansion interface{} + +// IPListerExpansion allows custom methods to be added to +// IPLister. +type IPListerExpansion interface{} + +// IPNamespaceListerExpansion allows custom methods to be added to +// IPNamespaceLister. +type IPNamespaceListerExpansion interface{} + +// IPAddressListerExpansion allows custom methods to be added to +// IPAddressLister. +type IPAddressListerExpansion interface{} + +// InstanceListerExpansion allows custom methods to be added to +// InstanceLister. +type InstanceListerExpansion interface{} + +// InstanceNamespaceListerExpansion allows custom methods to be added to +// InstanceNamespaceLister. +type InstanceNamespaceListerExpansion interface{} + +// LoadBalancerListerExpansion allows custom methods to be added to +// LoadBalancerLister. +type LoadBalancerListerExpansion interface{} + +// LoadBalancerNamespaceListerExpansion allows custom methods to be added to +// LoadBalancerNamespaceLister. +type LoadBalancerNamespaceListerExpansion interface{} + +// LoadBalancerRoutingListerExpansion allows custom methods to be added to +// LoadBalancerRoutingLister. +type LoadBalancerRoutingListerExpansion interface{} + +// LoadBalancerRoutingNamespaceListerExpansion allows custom methods to be added to +// LoadBalancerRoutingNamespaceLister. +type LoadBalancerRoutingNamespaceListerExpansion interface{} + +// NATGatewayListerExpansion allows custom methods to be added to +// NATGatewayLister. +type NATGatewayListerExpansion interface{} + +// NATGatewayNamespaceListerExpansion allows custom methods to be added to +// NATGatewayNamespaceLister. +type NATGatewayNamespaceListerExpansion interface{} + +// NATGatewayAutoscalerListerExpansion allows custom methods to be added to +// NATGatewayAutoscalerLister. +type NATGatewayAutoscalerListerExpansion interface{} + +// NATGatewayAutoscalerNamespaceListerExpansion allows custom methods to be added to +// NATGatewayAutoscalerNamespaceLister. +type NATGatewayAutoscalerNamespaceListerExpansion interface{} + +// NATTableListerExpansion allows custom methods to be added to +// NATTableLister. +type NATTableListerExpansion interface{} + +// NATTableNamespaceListerExpansion allows custom methods to be added to +// NATTableNamespaceLister. +type NATTableNamespaceListerExpansion interface{} + +// NetworkListerExpansion allows custom methods to be added to +// NetworkLister. +type NetworkListerExpansion interface{} + +// NetworkNamespaceListerExpansion allows custom methods to be added to +// NetworkNamespaceLister. +type NetworkNamespaceListerExpansion interface{} + +// NetworkIDListerExpansion allows custom methods to be added to +// NetworkIDLister. +type NetworkIDListerExpansion interface{} + +// NetworkInterfaceListerExpansion allows custom methods to be added to +// NetworkInterfaceLister. +type NetworkInterfaceListerExpansion interface{} + +// NetworkInterfaceNamespaceListerExpansion allows custom methods to be added to +// NetworkInterfaceNamespaceLister. +type NetworkInterfaceNamespaceListerExpansion interface{} + +// NodeListerExpansion allows custom methods to be added to +// NodeLister. +type NodeListerExpansion interface{} diff --git a/client-go/listers/core/v1alpha1/instance.go b/client-go/listers/core/v1alpha1/instance.go new file mode 100644 index 00000000..b468619b --- /dev/null +++ b/client-go/listers/core/v1alpha1/instance.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// InstanceLister helps list Instances. +// All objects returned here must be treated as read-only. +type InstanceLister interface { + // List lists all Instances in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Instance, err error) + // Instances returns an object that can list and get Instances. + Instances(namespace string) InstanceNamespaceLister + InstanceListerExpansion +} + +// instanceLister implements the InstanceLister interface. +type instanceLister struct { + indexer cache.Indexer +} + +// NewInstanceLister returns a new InstanceLister. +func NewInstanceLister(indexer cache.Indexer) InstanceLister { + return &instanceLister{indexer: indexer} +} + +// List lists all Instances in the indexer. +func (s *instanceLister) List(selector labels.Selector) (ret []*v1alpha1.Instance, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Instance)) + }) + return ret, err +} + +// Instances returns an object that can list and get Instances. +func (s *instanceLister) Instances(namespace string) InstanceNamespaceLister { + return instanceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// InstanceNamespaceLister helps list and get Instances. +// All objects returned here must be treated as read-only. +type InstanceNamespaceLister interface { + // List lists all Instances in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Instance, err error) + // Get retrieves the Instance from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Instance, error) + InstanceNamespaceListerExpansion +} + +// instanceNamespaceLister implements the InstanceNamespaceLister +// interface. +type instanceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Instances in the indexer for a given namespace. +func (s instanceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Instance, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Instance)) + }) + return ret, err +} + +// Get retrieves the Instance from the indexer for a given namespace and name. +func (s instanceNamespaceLister) Get(name string) (*v1alpha1.Instance, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("instance"), name) + } + return obj.(*v1alpha1.Instance), nil +} diff --git a/client-go/listers/core/v1alpha1/ip.go b/client-go/listers/core/v1alpha1/ip.go new file mode 100644 index 00000000..33bb46a0 --- /dev/null +++ b/client-go/listers/core/v1alpha1/ip.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// IPLister helps list IPs. +// All objects returned here must be treated as read-only. +type IPLister interface { + // List lists all IPs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.IP, err error) + // IPs returns an object that can list and get IPs. + IPs(namespace string) IPNamespaceLister + IPListerExpansion +} + +// iPLister implements the IPLister interface. +type iPLister struct { + indexer cache.Indexer +} + +// NewIPLister returns a new IPLister. +func NewIPLister(indexer cache.Indexer) IPLister { + return &iPLister{indexer: indexer} +} + +// List lists all IPs in the indexer. +func (s *iPLister) List(selector labels.Selector) (ret []*v1alpha1.IP, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IP)) + }) + return ret, err +} + +// IPs returns an object that can list and get IPs. +func (s *iPLister) IPs(namespace string) IPNamespaceLister { + return iPNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IPNamespaceLister helps list and get IPs. +// All objects returned here must be treated as read-only. +type IPNamespaceLister interface { + // List lists all IPs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.IP, err error) + // Get retrieves the IP from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.IP, error) + IPNamespaceListerExpansion +} + +// iPNamespaceLister implements the IPNamespaceLister +// interface. +type iPNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all IPs in the indexer for a given namespace. +func (s iPNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.IP, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IP)) + }) + return ret, err +} + +// Get retrieves the IP from the indexer for a given namespace and name. +func (s iPNamespaceLister) Get(name string) (*v1alpha1.IP, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ip"), name) + } + return obj.(*v1alpha1.IP), nil +} diff --git a/client-go/listers/core/v1alpha1/ipaddress.go b/client-go/listers/core/v1alpha1/ipaddress.go new file mode 100644 index 00000000..047235af --- /dev/null +++ b/client-go/listers/core/v1alpha1/ipaddress.go @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// IPAddressLister helps list IPAddresses. +// All objects returned here must be treated as read-only. +type IPAddressLister interface { + // List lists all IPAddresses in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.IPAddress, err error) + // Get retrieves the IPAddress from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.IPAddress, error) + IPAddressListerExpansion +} + +// iPAddressLister implements the IPAddressLister interface. +type iPAddressLister struct { + indexer cache.Indexer +} + +// NewIPAddressLister returns a new IPAddressLister. +func NewIPAddressLister(indexer cache.Indexer) IPAddressLister { + return &iPAddressLister{indexer: indexer} +} + +// List lists all IPAddresses in the indexer. +func (s *iPAddressLister) List(selector labels.Selector) (ret []*v1alpha1.IPAddress, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IPAddress)) + }) + return ret, err +} + +// Get retrieves the IPAddress from the index for a given name. +func (s *iPAddressLister) Get(name string) (*v1alpha1.IPAddress, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ipaddress"), name) + } + return obj.(*v1alpha1.IPAddress), nil +} diff --git a/client-go/listers/core/v1alpha1/loadbalancer.go b/client-go/listers/core/v1alpha1/loadbalancer.go new file mode 100644 index 00000000..e139c9d8 --- /dev/null +++ b/client-go/listers/core/v1alpha1/loadbalancer.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// LoadBalancerLister helps list LoadBalancers. +// All objects returned here must be treated as read-only. +type LoadBalancerLister interface { + // List lists all LoadBalancers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.LoadBalancer, err error) + // LoadBalancers returns an object that can list and get LoadBalancers. + LoadBalancers(namespace string) LoadBalancerNamespaceLister + LoadBalancerListerExpansion +} + +// loadBalancerLister implements the LoadBalancerLister interface. +type loadBalancerLister struct { + indexer cache.Indexer +} + +// NewLoadBalancerLister returns a new LoadBalancerLister. +func NewLoadBalancerLister(indexer cache.Indexer) LoadBalancerLister { + return &loadBalancerLister{indexer: indexer} +} + +// List lists all LoadBalancers in the indexer. +func (s *loadBalancerLister) List(selector labels.Selector) (ret []*v1alpha1.LoadBalancer, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.LoadBalancer)) + }) + return ret, err +} + +// LoadBalancers returns an object that can list and get LoadBalancers. +func (s *loadBalancerLister) LoadBalancers(namespace string) LoadBalancerNamespaceLister { + return loadBalancerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// LoadBalancerNamespaceLister helps list and get LoadBalancers. +// All objects returned here must be treated as read-only. +type LoadBalancerNamespaceLister interface { + // List lists all LoadBalancers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.LoadBalancer, err error) + // Get retrieves the LoadBalancer from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.LoadBalancer, error) + LoadBalancerNamespaceListerExpansion +} + +// loadBalancerNamespaceLister implements the LoadBalancerNamespaceLister +// interface. +type loadBalancerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all LoadBalancers in the indexer for a given namespace. +func (s loadBalancerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.LoadBalancer, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.LoadBalancer)) + }) + return ret, err +} + +// Get retrieves the LoadBalancer from the indexer for a given namespace and name. +func (s loadBalancerNamespaceLister) Get(name string) (*v1alpha1.LoadBalancer, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("loadbalancer"), name) + } + return obj.(*v1alpha1.LoadBalancer), nil +} diff --git a/client-go/listers/core/v1alpha1/loadbalancerrouting.go b/client-go/listers/core/v1alpha1/loadbalancerrouting.go new file mode 100644 index 00000000..6cdb1adc --- /dev/null +++ b/client-go/listers/core/v1alpha1/loadbalancerrouting.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// LoadBalancerRoutingLister helps list LoadBalancerRoutings. +// All objects returned here must be treated as read-only. +type LoadBalancerRoutingLister interface { + // List lists all LoadBalancerRoutings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.LoadBalancerRouting, err error) + // LoadBalancerRoutings returns an object that can list and get LoadBalancerRoutings. + LoadBalancerRoutings(namespace string) LoadBalancerRoutingNamespaceLister + LoadBalancerRoutingListerExpansion +} + +// loadBalancerRoutingLister implements the LoadBalancerRoutingLister interface. +type loadBalancerRoutingLister struct { + indexer cache.Indexer +} + +// NewLoadBalancerRoutingLister returns a new LoadBalancerRoutingLister. +func NewLoadBalancerRoutingLister(indexer cache.Indexer) LoadBalancerRoutingLister { + return &loadBalancerRoutingLister{indexer: indexer} +} + +// List lists all LoadBalancerRoutings in the indexer. +func (s *loadBalancerRoutingLister) List(selector labels.Selector) (ret []*v1alpha1.LoadBalancerRouting, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.LoadBalancerRouting)) + }) + return ret, err +} + +// LoadBalancerRoutings returns an object that can list and get LoadBalancerRoutings. +func (s *loadBalancerRoutingLister) LoadBalancerRoutings(namespace string) LoadBalancerRoutingNamespaceLister { + return loadBalancerRoutingNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// LoadBalancerRoutingNamespaceLister helps list and get LoadBalancerRoutings. +// All objects returned here must be treated as read-only. +type LoadBalancerRoutingNamespaceLister interface { + // List lists all LoadBalancerRoutings in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.LoadBalancerRouting, err error) + // Get retrieves the LoadBalancerRouting from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.LoadBalancerRouting, error) + LoadBalancerRoutingNamespaceListerExpansion +} + +// loadBalancerRoutingNamespaceLister implements the LoadBalancerRoutingNamespaceLister +// interface. +type loadBalancerRoutingNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all LoadBalancerRoutings in the indexer for a given namespace. +func (s loadBalancerRoutingNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.LoadBalancerRouting, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.LoadBalancerRouting)) + }) + return ret, err +} + +// Get retrieves the LoadBalancerRouting from the indexer for a given namespace and name. +func (s loadBalancerRoutingNamespaceLister) Get(name string) (*v1alpha1.LoadBalancerRouting, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("loadbalancerrouting"), name) + } + return obj.(*v1alpha1.LoadBalancerRouting), nil +} diff --git a/client-go/listers/core/v1alpha1/natgateway.go b/client-go/listers/core/v1alpha1/natgateway.go new file mode 100644 index 00000000..5a37d8f4 --- /dev/null +++ b/client-go/listers/core/v1alpha1/natgateway.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NATGatewayLister helps list NATGateways. +// All objects returned here must be treated as read-only. +type NATGatewayLister interface { + // List lists all NATGateways in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATGateway, err error) + // NATGateways returns an object that can list and get NATGateways. + NATGateways(namespace string) NATGatewayNamespaceLister + NATGatewayListerExpansion +} + +// nATGatewayLister implements the NATGatewayLister interface. +type nATGatewayLister struct { + indexer cache.Indexer +} + +// NewNATGatewayLister returns a new NATGatewayLister. +func NewNATGatewayLister(indexer cache.Indexer) NATGatewayLister { + return &nATGatewayLister{indexer: indexer} +} + +// List lists all NATGateways in the indexer. +func (s *nATGatewayLister) List(selector labels.Selector) (ret []*v1alpha1.NATGateway, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATGateway)) + }) + return ret, err +} + +// NATGateways returns an object that can list and get NATGateways. +func (s *nATGatewayLister) NATGateways(namespace string) NATGatewayNamespaceLister { + return nATGatewayNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// NATGatewayNamespaceLister helps list and get NATGateways. +// All objects returned here must be treated as read-only. +type NATGatewayNamespaceLister interface { + // List lists all NATGateways in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATGateway, err error) + // Get retrieves the NATGateway from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NATGateway, error) + NATGatewayNamespaceListerExpansion +} + +// nATGatewayNamespaceLister implements the NATGatewayNamespaceLister +// interface. +type nATGatewayNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all NATGateways in the indexer for a given namespace. +func (s nATGatewayNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NATGateway, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATGateway)) + }) + return ret, err +} + +// Get retrieves the NATGateway from the indexer for a given namespace and name. +func (s nATGatewayNamespaceLister) Get(name string) (*v1alpha1.NATGateway, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("natgateway"), name) + } + return obj.(*v1alpha1.NATGateway), nil +} diff --git a/client-go/listers/core/v1alpha1/natgatewayautoscaler.go b/client-go/listers/core/v1alpha1/natgatewayautoscaler.go new file mode 100644 index 00000000..1f241f6d --- /dev/null +++ b/client-go/listers/core/v1alpha1/natgatewayautoscaler.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NATGatewayAutoscalerLister helps list NATGatewayAutoscalers. +// All objects returned here must be treated as read-only. +type NATGatewayAutoscalerLister interface { + // List lists all NATGatewayAutoscalers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATGatewayAutoscaler, err error) + // NATGatewayAutoscalers returns an object that can list and get NATGatewayAutoscalers. + NATGatewayAutoscalers(namespace string) NATGatewayAutoscalerNamespaceLister + NATGatewayAutoscalerListerExpansion +} + +// nATGatewayAutoscalerLister implements the NATGatewayAutoscalerLister interface. +type nATGatewayAutoscalerLister struct { + indexer cache.Indexer +} + +// NewNATGatewayAutoscalerLister returns a new NATGatewayAutoscalerLister. +func NewNATGatewayAutoscalerLister(indexer cache.Indexer) NATGatewayAutoscalerLister { + return &nATGatewayAutoscalerLister{indexer: indexer} +} + +// List lists all NATGatewayAutoscalers in the indexer. +func (s *nATGatewayAutoscalerLister) List(selector labels.Selector) (ret []*v1alpha1.NATGatewayAutoscaler, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATGatewayAutoscaler)) + }) + return ret, err +} + +// NATGatewayAutoscalers returns an object that can list and get NATGatewayAutoscalers. +func (s *nATGatewayAutoscalerLister) NATGatewayAutoscalers(namespace string) NATGatewayAutoscalerNamespaceLister { + return nATGatewayAutoscalerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// NATGatewayAutoscalerNamespaceLister helps list and get NATGatewayAutoscalers. +// All objects returned here must be treated as read-only. +type NATGatewayAutoscalerNamespaceLister interface { + // List lists all NATGatewayAutoscalers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATGatewayAutoscaler, err error) + // Get retrieves the NATGatewayAutoscaler from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NATGatewayAutoscaler, error) + NATGatewayAutoscalerNamespaceListerExpansion +} + +// nATGatewayAutoscalerNamespaceLister implements the NATGatewayAutoscalerNamespaceLister +// interface. +type nATGatewayAutoscalerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all NATGatewayAutoscalers in the indexer for a given namespace. +func (s nATGatewayAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NATGatewayAutoscaler, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATGatewayAutoscaler)) + }) + return ret, err +} + +// Get retrieves the NATGatewayAutoscaler from the indexer for a given namespace and name. +func (s nATGatewayAutoscalerNamespaceLister) Get(name string) (*v1alpha1.NATGatewayAutoscaler, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("natgatewayautoscaler"), name) + } + return obj.(*v1alpha1.NATGatewayAutoscaler), nil +} diff --git a/client-go/listers/core/v1alpha1/nattable.go b/client-go/listers/core/v1alpha1/nattable.go new file mode 100644 index 00000000..ef5343ec --- /dev/null +++ b/client-go/listers/core/v1alpha1/nattable.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NATTableLister helps list NATTables. +// All objects returned here must be treated as read-only. +type NATTableLister interface { + // List lists all NATTables in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATTable, err error) + // NATTables returns an object that can list and get NATTables. + NATTables(namespace string) NATTableNamespaceLister + NATTableListerExpansion +} + +// nATTableLister implements the NATTableLister interface. +type nATTableLister struct { + indexer cache.Indexer +} + +// NewNATTableLister returns a new NATTableLister. +func NewNATTableLister(indexer cache.Indexer) NATTableLister { + return &nATTableLister{indexer: indexer} +} + +// List lists all NATTables in the indexer. +func (s *nATTableLister) List(selector labels.Selector) (ret []*v1alpha1.NATTable, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATTable)) + }) + return ret, err +} + +// NATTables returns an object that can list and get NATTables. +func (s *nATTableLister) NATTables(namespace string) NATTableNamespaceLister { + return nATTableNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// NATTableNamespaceLister helps list and get NATTables. +// All objects returned here must be treated as read-only. +type NATTableNamespaceLister interface { + // List lists all NATTables in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NATTable, err error) + // Get retrieves the NATTable from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NATTable, error) + NATTableNamespaceListerExpansion +} + +// nATTableNamespaceLister implements the NATTableNamespaceLister +// interface. +type nATTableNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all NATTables in the indexer for a given namespace. +func (s nATTableNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NATTable, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NATTable)) + }) + return ret, err +} + +// Get retrieves the NATTable from the indexer for a given namespace and name. +func (s nATTableNamespaceLister) Get(name string) (*v1alpha1.NATTable, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("nattable"), name) + } + return obj.(*v1alpha1.NATTable), nil +} diff --git a/client-go/listers/core/v1alpha1/network.go b/client-go/listers/core/v1alpha1/network.go new file mode 100644 index 00000000..00386453 --- /dev/null +++ b/client-go/listers/core/v1alpha1/network.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NetworkLister helps list Networks. +// All objects returned here must be treated as read-only. +type NetworkLister interface { + // List lists all Networks in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Network, err error) + // Networks returns an object that can list and get Networks. + Networks(namespace string) NetworkNamespaceLister + NetworkListerExpansion +} + +// networkLister implements the NetworkLister interface. +type networkLister struct { + indexer cache.Indexer +} + +// NewNetworkLister returns a new NetworkLister. +func NewNetworkLister(indexer cache.Indexer) NetworkLister { + return &networkLister{indexer: indexer} +} + +// List lists all Networks in the indexer. +func (s *networkLister) List(selector labels.Selector) (ret []*v1alpha1.Network, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Network)) + }) + return ret, err +} + +// Networks returns an object that can list and get Networks. +func (s *networkLister) Networks(namespace string) NetworkNamespaceLister { + return networkNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// NetworkNamespaceLister helps list and get Networks. +// All objects returned here must be treated as read-only. +type NetworkNamespaceLister interface { + // List lists all Networks in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Network, err error) + // Get retrieves the Network from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Network, error) + NetworkNamespaceListerExpansion +} + +// networkNamespaceLister implements the NetworkNamespaceLister +// interface. +type networkNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Networks in the indexer for a given namespace. +func (s networkNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Network, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Network)) + }) + return ret, err +} + +// Get retrieves the Network from the indexer for a given namespace and name. +func (s networkNamespaceLister) Get(name string) (*v1alpha1.Network, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("network"), name) + } + return obj.(*v1alpha1.Network), nil +} diff --git a/client-go/listers/core/v1alpha1/networkid.go b/client-go/listers/core/v1alpha1/networkid.go new file mode 100644 index 00000000..2ff72641 --- /dev/null +++ b/client-go/listers/core/v1alpha1/networkid.go @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NetworkIDLister helps list NetworkIDs. +// All objects returned here must be treated as read-only. +type NetworkIDLister interface { + // List lists all NetworkIDs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NetworkID, err error) + // Get retrieves the NetworkID from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NetworkID, error) + NetworkIDListerExpansion +} + +// networkIDLister implements the NetworkIDLister interface. +type networkIDLister struct { + indexer cache.Indexer +} + +// NewNetworkIDLister returns a new NetworkIDLister. +func NewNetworkIDLister(indexer cache.Indexer) NetworkIDLister { + return &networkIDLister{indexer: indexer} +} + +// List lists all NetworkIDs in the indexer. +func (s *networkIDLister) List(selector labels.Selector) (ret []*v1alpha1.NetworkID, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NetworkID)) + }) + return ret, err +} + +// Get retrieves the NetworkID from the index for a given name. +func (s *networkIDLister) Get(name string) (*v1alpha1.NetworkID, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("networkid"), name) + } + return obj.(*v1alpha1.NetworkID), nil +} diff --git a/client-go/listers/core/v1alpha1/networkinterface.go b/client-go/listers/core/v1alpha1/networkinterface.go new file mode 100644 index 00000000..30acb596 --- /dev/null +++ b/client-go/listers/core/v1alpha1/networkinterface.go @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NetworkInterfaceLister helps list NetworkInterfaces. +// All objects returned here must be treated as read-only. +type NetworkInterfaceLister interface { + // List lists all NetworkInterfaces in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NetworkInterface, err error) + // NetworkInterfaces returns an object that can list and get NetworkInterfaces. + NetworkInterfaces(namespace string) NetworkInterfaceNamespaceLister + NetworkInterfaceListerExpansion +} + +// networkInterfaceLister implements the NetworkInterfaceLister interface. +type networkInterfaceLister struct { + indexer cache.Indexer +} + +// NewNetworkInterfaceLister returns a new NetworkInterfaceLister. +func NewNetworkInterfaceLister(indexer cache.Indexer) NetworkInterfaceLister { + return &networkInterfaceLister{indexer: indexer} +} + +// List lists all NetworkInterfaces in the indexer. +func (s *networkInterfaceLister) List(selector labels.Selector) (ret []*v1alpha1.NetworkInterface, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NetworkInterface)) + }) + return ret, err +} + +// NetworkInterfaces returns an object that can list and get NetworkInterfaces. +func (s *networkInterfaceLister) NetworkInterfaces(namespace string) NetworkInterfaceNamespaceLister { + return networkInterfaceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// NetworkInterfaceNamespaceLister helps list and get NetworkInterfaces. +// All objects returned here must be treated as read-only. +type NetworkInterfaceNamespaceLister interface { + // List lists all NetworkInterfaces in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NetworkInterface, err error) + // Get retrieves the NetworkInterface from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NetworkInterface, error) + NetworkInterfaceNamespaceListerExpansion +} + +// networkInterfaceNamespaceLister implements the NetworkInterfaceNamespaceLister +// interface. +type networkInterfaceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all NetworkInterfaces in the indexer for a given namespace. +func (s networkInterfaceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NetworkInterface, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NetworkInterface)) + }) + return ret, err +} + +// Get retrieves the NetworkInterface from the indexer for a given namespace and name. +func (s networkInterfaceNamespaceLister) Get(name string) (*v1alpha1.NetworkInterface, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("networkinterface"), name) + } + return obj.(*v1alpha1.NetworkInterface), nil +} diff --git a/client-go/listers/core/v1alpha1/node.go b/client-go/listers/core/v1alpha1/node.go new file mode 100644 index 00000000..7e94a59c --- /dev/null +++ b/client-go/listers/core/v1alpha1/node.go @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NodeLister helps list Nodes. +// All objects returned here must be treated as read-only. +type NodeLister interface { + // List lists all Nodes in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Node, err error) + // Get retrieves the Node from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Node, error) + NodeListerExpansion +} + +// nodeLister implements the NodeLister interface. +type nodeLister struct { + indexer cache.Indexer +} + +// NewNodeLister returns a new NodeLister. +func NewNodeLister(indexer cache.Indexer) NodeLister { + return &nodeLister{indexer: indexer} +} + +// List lists all Nodes in the indexer. +func (s *nodeLister) List(selector labels.Selector) (ret []*v1alpha1.Node, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Node)) + }) + return ret, err +} + +// Get retrieves the Node from the index for a given name. +func (s *nodeLister) Get(name string) (*v1alpha1.Node, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("node"), name) + } + return obj.(*v1alpha1.Node), nil +} diff --git a/client-go/onmetalapinet/clientset.go b/client-go/onmetalapinet/clientset.go new file mode 100644 index 00000000..78d75e61 --- /dev/null +++ b/client-go/onmetalapinet/clientset.go @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package onmetalapinet + +import ( + "fmt" + "net/http" + + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + coreV1alpha1 *corev1alpha1.CoreV1alpha1Client +} + +// CoreV1alpha1 retrieves the CoreV1alpha1Client +func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { + return c.coreV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.coreV1alpha1, err = corev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.coreV1alpha1 = corev1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/client-go/onmetalapinet/fake/clientset_generated.go b/client-go/onmetalapinet/fake/clientset_generated.go new file mode 100644 index 00000000..ee407512 --- /dev/null +++ b/client-go/onmetalapinet/fake/clientset_generated.go @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + fakecorev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// CoreV1alpha1 retrieves the CoreV1alpha1Client +func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { + return &fakecorev1alpha1.FakeCoreV1alpha1{Fake: &c.Fake} +} diff --git a/client-go/onmetalapinet/fake/doc.go b/client-go/onmetalapinet/fake/doc.go new file mode 100644 index 00000000..ee853b06 --- /dev/null +++ b/client-go/onmetalapinet/fake/doc.go @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/client-go/onmetalapinet/fake/register.go b/client-go/onmetalapinet/fake/register.go new file mode 100644 index 00000000..c35a2bca --- /dev/null +++ b/client-go/onmetalapinet/fake/register.go @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + corev1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/client-go/onmetalapinet/scheme/doc.go b/client-go/onmetalapinet/scheme/doc.go new file mode 100644 index 00000000..740c73b5 --- /dev/null +++ b/client-go/onmetalapinet/scheme/doc.go @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/client-go/onmetalapinet/scheme/register.go b/client-go/onmetalapinet/scheme/register.go new file mode 100644 index 00000000..ce7731dc --- /dev/null +++ b/client-go/onmetalapinet/scheme/register.go @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package scheme + +import ( + corev1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + corev1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/core_client.go b/client-go/onmetalapinet/typed/core/v1alpha1/core_client.go new file mode 100644 index 00000000..a97a0775 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/core_client.go @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + rest "k8s.io/client-go/rest" +) + +type CoreV1alpha1Interface interface { + RESTClient() rest.Interface + DaemonSetsGetter + IPsGetter + IPAddressesGetter + InstancesGetter + LoadBalancersGetter + LoadBalancerRoutingsGetter + NATGatewaysGetter + NATGatewayAutoscalersGetter + NATTablesGetter + NetworksGetter + NetworkIDsGetter + NetworkInterfacesGetter + NodesGetter +} + +// CoreV1alpha1Client is used to interact with features provided by the core.apinet.api.onmetal.de group. +type CoreV1alpha1Client struct { + restClient rest.Interface +} + +func (c *CoreV1alpha1Client) DaemonSets(namespace string) DaemonSetInterface { + return newDaemonSets(c, namespace) +} + +func (c *CoreV1alpha1Client) IPs(namespace string) IPInterface { + return newIPs(c, namespace) +} + +func (c *CoreV1alpha1Client) IPAddresses() IPAddressInterface { + return newIPAddresses(c) +} + +func (c *CoreV1alpha1Client) Instances(namespace string) InstanceInterface { + return newInstances(c, namespace) +} + +func (c *CoreV1alpha1Client) LoadBalancers(namespace string) LoadBalancerInterface { + return newLoadBalancers(c, namespace) +} + +func (c *CoreV1alpha1Client) LoadBalancerRoutings(namespace string) LoadBalancerRoutingInterface { + return newLoadBalancerRoutings(c, namespace) +} + +func (c *CoreV1alpha1Client) NATGateways(namespace string) NATGatewayInterface { + return newNATGateways(c, namespace) +} + +func (c *CoreV1alpha1Client) NATGatewayAutoscalers(namespace string) NATGatewayAutoscalerInterface { + return newNATGatewayAutoscalers(c, namespace) +} + +func (c *CoreV1alpha1Client) NATTables(namespace string) NATTableInterface { + return newNATTables(c, namespace) +} + +func (c *CoreV1alpha1Client) Networks(namespace string) NetworkInterface { + return newNetworks(c, namespace) +} + +func (c *CoreV1alpha1Client) NetworkIDs() NetworkIDInterface { + return newNetworkIDs(c) +} + +func (c *CoreV1alpha1Client) NetworkInterfaces(namespace string) NetworkInterfaceInterface { + return newNetworkInterfaces(c, namespace) +} + +func (c *CoreV1alpha1Client) Nodes() NodeInterface { + return newNodes(c) +} + +// NewForConfig creates a new CoreV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*CoreV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new CoreV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoreV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &CoreV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new CoreV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *CoreV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new CoreV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *CoreV1alpha1Client { + return &CoreV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *CoreV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/daemonset.go b/client-go/onmetalapinet/typed/core/v1alpha1/daemonset.go new file mode 100644 index 00000000..ae196f90 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/daemonset.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// DaemonSetsGetter has a method to return a DaemonSetInterface. +// A group's client should implement this interface. +type DaemonSetsGetter interface { + DaemonSets(namespace string) DaemonSetInterface +} + +// DaemonSetInterface has methods to work with DaemonSet resources. +type DaemonSetInterface interface { + Create(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.CreateOptions) (*v1alpha1.DaemonSet, error) + Update(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (*v1alpha1.DaemonSet, error) + UpdateStatus(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (*v1alpha1.DaemonSet, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.DaemonSet, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.DaemonSetList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaemonSet, err error) + Apply(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) + ApplyStatus(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) + DaemonSetExpansion +} + +// daemonSets implements DaemonSetInterface +type daemonSets struct { + client rest.Interface + ns string +} + +// newDaemonSets returns a DaemonSets +func newDaemonSets(c *CoreV1alpha1Client, namespace string) *daemonSets { + return &daemonSets{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the daemonSet, and returns the corresponding daemonSet object, and an error if there is any. +func (c *daemonSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaemonSet, err error) { + result = &v1alpha1.DaemonSet{} + err = c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of DaemonSets that match those selectors. +func (c *daemonSets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaemonSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.DaemonSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested daemonSets. +func (c *daemonSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a daemonSet and creates it. Returns the server's representation of the daemonSet, and an error, if there is any. +func (c *daemonSets) Create(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.CreateOptions) (result *v1alpha1.DaemonSet, err error) { + result = &v1alpha1.DaemonSet{} + err = c.client.Post(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(daemonSet). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a daemonSet and updates it. Returns the server's representation of the daemonSet, and an error, if there is any. +func (c *daemonSets) Update(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (result *v1alpha1.DaemonSet, err error) { + result = &v1alpha1.DaemonSet{} + err = c.client.Put(). + Namespace(c.ns). + Resource("daemonsets"). + Name(daemonSet.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(daemonSet). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *daemonSets) UpdateStatus(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (result *v1alpha1.DaemonSet, err error) { + result = &v1alpha1.DaemonSet{} + err = c.client.Put(). + Namespace(c.ns). + Resource("daemonsets"). + Name(daemonSet.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(daemonSet). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the daemonSet and deletes it. Returns an error if one occurs. +func (c *daemonSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("daemonsets"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *daemonSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched daemonSet. +func (c *daemonSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaemonSet, err error) { + result = &v1alpha1.DaemonSet{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("daemonsets"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied daemonSet. +func (c *daemonSets) Apply(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) { + if daemonSet == nil { + return nil, fmt.Errorf("daemonSet provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(daemonSet) + if err != nil { + return nil, err + } + name := daemonSet.Name + if name == nil { + return nil, fmt.Errorf("daemonSet.Name must be provided to Apply") + } + result = &v1alpha1.DaemonSet{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("daemonsets"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *daemonSets) ApplyStatus(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) { + if daemonSet == nil { + return nil, fmt.Errorf("daemonSet provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(daemonSet) + if err != nil { + return nil, err + } + + name := daemonSet.Name + if name == nil { + return nil, fmt.Errorf("daemonSet.Name must be provided to Apply") + } + + result = &v1alpha1.DaemonSet{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("daemonsets"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/doc.go b/client-go/onmetalapinet/typed/core/v1alpha1/doc.go new file mode 100644 index 00000000..5f4c971a --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/doc.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/doc.go new file mode 100644 index 00000000..82bfa735 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/doc.go @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_core_client.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_core_client.go new file mode 100644 index 00000000..34bea10a --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_core_client.go @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeCoreV1alpha1 struct { + *testing.Fake +} + +func (c *FakeCoreV1alpha1) DaemonSets(namespace string) v1alpha1.DaemonSetInterface { + return &FakeDaemonSets{c, namespace} +} + +func (c *FakeCoreV1alpha1) IPs(namespace string) v1alpha1.IPInterface { + return &FakeIPs{c, namespace} +} + +func (c *FakeCoreV1alpha1) IPAddresses() v1alpha1.IPAddressInterface { + return &FakeIPAddresses{c} +} + +func (c *FakeCoreV1alpha1) Instances(namespace string) v1alpha1.InstanceInterface { + return &FakeInstances{c, namespace} +} + +func (c *FakeCoreV1alpha1) LoadBalancers(namespace string) v1alpha1.LoadBalancerInterface { + return &FakeLoadBalancers{c, namespace} +} + +func (c *FakeCoreV1alpha1) LoadBalancerRoutings(namespace string) v1alpha1.LoadBalancerRoutingInterface { + return &FakeLoadBalancerRoutings{c, namespace} +} + +func (c *FakeCoreV1alpha1) NATGateways(namespace string) v1alpha1.NATGatewayInterface { + return &FakeNATGateways{c, namespace} +} + +func (c *FakeCoreV1alpha1) NATGatewayAutoscalers(namespace string) v1alpha1.NATGatewayAutoscalerInterface { + return &FakeNATGatewayAutoscalers{c, namespace} +} + +func (c *FakeCoreV1alpha1) NATTables(namespace string) v1alpha1.NATTableInterface { + return &FakeNATTables{c, namespace} +} + +func (c *FakeCoreV1alpha1) Networks(namespace string) v1alpha1.NetworkInterface { + return &FakeNetworks{c, namespace} +} + +func (c *FakeCoreV1alpha1) NetworkIDs() v1alpha1.NetworkIDInterface { + return &FakeNetworkIDs{c} +} + +func (c *FakeCoreV1alpha1) NetworkInterfaces(namespace string) v1alpha1.NetworkInterfaceInterface { + return &FakeNetworkInterfaces{c, namespace} +} + +func (c *FakeCoreV1alpha1) Nodes() v1alpha1.NodeInterface { + return &FakeNodes{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeCoreV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_daemonset.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_daemonset.go new file mode 100644 index 00000000..61781311 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_daemonset.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeDaemonSets implements DaemonSetInterface +type FakeDaemonSets struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var daemonsetsResource = v1alpha1.SchemeGroupVersion.WithResource("daemonsets") + +var daemonsetsKind = v1alpha1.SchemeGroupVersion.WithKind("DaemonSet") + +// Get takes name of the daemonSet, and returns the corresponding daemonSet object, and an error if there is any. +func (c *FakeDaemonSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaemonSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(daemonsetsResource, c.ns, name), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// List takes label and field selectors, and returns the list of DaemonSets that match those selectors. +func (c *FakeDaemonSets) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaemonSetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(daemonsetsResource, daemonsetsKind, c.ns, opts), &v1alpha1.DaemonSetList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.DaemonSetList{ListMeta: obj.(*v1alpha1.DaemonSetList).ListMeta} + for _, item := range obj.(*v1alpha1.DaemonSetList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested daemonSets. +func (c *FakeDaemonSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(daemonsetsResource, c.ns, opts)) + +} + +// Create takes the representation of a daemonSet and creates it. Returns the server's representation of the daemonSet, and an error, if there is any. +func (c *FakeDaemonSets) Create(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.CreateOptions) (result *v1alpha1.DaemonSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(daemonsetsResource, c.ns, daemonSet), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// Update takes the representation of a daemonSet and updates it. Returns the server's representation of the daemonSet, and an error, if there is any. +func (c *FakeDaemonSets) Update(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (result *v1alpha1.DaemonSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(daemonsetsResource, c.ns, daemonSet), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeDaemonSets) UpdateStatus(ctx context.Context, daemonSet *v1alpha1.DaemonSet, opts v1.UpdateOptions) (*v1alpha1.DaemonSet, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(daemonsetsResource, "status", c.ns, daemonSet), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// Delete takes name of the daemonSet and deletes it. Returns an error if one occurs. +func (c *FakeDaemonSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(daemonsetsResource, c.ns, name, opts), &v1alpha1.DaemonSet{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeDaemonSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(daemonsetsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.DaemonSetList{}) + return err +} + +// Patch applies the patch and returns the patched daemonSet. +func (c *FakeDaemonSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaemonSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, pt, data, subresources...), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied daemonSet. +func (c *FakeDaemonSets) Apply(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) { + if daemonSet == nil { + return nil, fmt.Errorf("daemonSet provided to Apply must not be nil") + } + data, err := json.Marshal(daemonSet) + if err != nil { + return nil, err + } + name := daemonSet.Name + if name == nil { + return nil, fmt.Errorf("daemonSet.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeDaemonSets) ApplyStatus(ctx context.Context, daemonSet *corev1alpha1.DaemonSetApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaemonSet, err error) { + if daemonSet == nil { + return nil, fmt.Errorf("daemonSet provided to Apply must not be nil") + } + data, err := json.Marshal(daemonSet) + if err != nil { + return nil, err + } + name := daemonSet.Name + if name == nil { + return nil, fmt.Errorf("daemonSet.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.DaemonSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.DaemonSet), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_instance.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_instance.go new file mode 100644 index 00000000..ac6e6a3a --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_instance.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeInstances implements InstanceInterface +type FakeInstances struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var instancesResource = v1alpha1.SchemeGroupVersion.WithResource("instances") + +var instancesKind = v1alpha1.SchemeGroupVersion.WithKind("Instance") + +// Get takes name of the instance, and returns the corresponding instance object, and an error if there is any. +func (c *FakeInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Instance, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(instancesResource, c.ns, name), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// List takes label and field selectors, and returns the list of Instances that match those selectors. +func (c *FakeInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstanceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(instancesResource, instancesKind, c.ns, opts), &v1alpha1.InstanceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.InstanceList{ListMeta: obj.(*v1alpha1.InstanceList).ListMeta} + for _, item := range obj.(*v1alpha1.InstanceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested instances. +func (c *FakeInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(instancesResource, c.ns, opts)) + +} + +// Create takes the representation of a instance and creates it. Returns the server's representation of the instance, and an error, if there is any. +func (c *FakeInstances) Create(ctx context.Context, instance *v1alpha1.Instance, opts v1.CreateOptions) (result *v1alpha1.Instance, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(instancesResource, c.ns, instance), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// Update takes the representation of a instance and updates it. Returns the server's representation of the instance, and an error, if there is any. +func (c *FakeInstances) Update(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (result *v1alpha1.Instance, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(instancesResource, c.ns, instance), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeInstances) UpdateStatus(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (*v1alpha1.Instance, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(instancesResource, "status", c.ns, instance), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// Delete takes name of the instance and deletes it. Returns an error if one occurs. +func (c *FakeInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(instancesResource, c.ns, name, opts), &v1alpha1.Instance{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(instancesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.InstanceList{}) + return err +} + +// Patch applies the patch and returns the patched instance. +func (c *FakeInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Instance, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instancesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied instance. +func (c *FakeInstances) Apply(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) { + if instance == nil { + return nil, fmt.Errorf("instance provided to Apply must not be nil") + } + data, err := json.Marshal(instance) + if err != nil { + return nil, err + } + name := instance.Name + if name == nil { + return nil, fmt.Errorf("instance.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instancesResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeInstances) ApplyStatus(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) { + if instance == nil { + return nil, fmt.Errorf("instance provided to Apply must not be nil") + } + data, err := json.Marshal(instance) + if err != nil { + return nil, err + } + name := instance.Name + if name == nil { + return nil, fmt.Errorf("instance.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instancesResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Instance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Instance), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ip.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ip.go new file mode 100644 index 00000000..1c8ebd4f --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ip.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeIPs implements IPInterface +type FakeIPs struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var ipsResource = v1alpha1.SchemeGroupVersion.WithResource("ips") + +var ipsKind = v1alpha1.SchemeGroupVersion.WithKind("IP") + +// Get takes name of the iP, and returns the corresponding iP object, and an error if there is any. +func (c *FakeIPs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IP, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ipsResource, c.ns, name), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// List takes label and field selectors, and returns the list of IPs that match those selectors. +func (c *FakeIPs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ipsResource, ipsKind, c.ns, opts), &v1alpha1.IPList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IPList{ListMeta: obj.(*v1alpha1.IPList).ListMeta} + for _, item := range obj.(*v1alpha1.IPList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested iPs. +func (c *FakeIPs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ipsResource, c.ns, opts)) + +} + +// Create takes the representation of a iP and creates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *FakeIPs) Create(ctx context.Context, iP *v1alpha1.IP, opts v1.CreateOptions) (result *v1alpha1.IP, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ipsResource, c.ns, iP), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// Update takes the representation of a iP and updates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *FakeIPs) Update(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (result *v1alpha1.IP, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ipsResource, c.ns, iP), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeIPs) UpdateStatus(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (*v1alpha1.IP, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(ipsResource, "status", c.ns, iP), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// Delete takes name of the iP and deletes it. Returns an error if one occurs. +func (c *FakeIPs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(ipsResource, c.ns, name, opts), &v1alpha1.IP{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIPs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ipsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.IPList{}) + return err +} + +// Patch applies the patch and returns the patched iP. +func (c *FakeIPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IP, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ipsResource, c.ns, name, pt, data, subresources...), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied iP. +func (c *FakeIPs) Apply(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) { + if iP == nil { + return nil, fmt.Errorf("iP provided to Apply must not be nil") + } + data, err := json.Marshal(iP) + if err != nil { + return nil, err + } + name := iP.Name + if name == nil { + return nil, fmt.Errorf("iP.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ipsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeIPs) ApplyStatus(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) { + if iP == nil { + return nil, fmt.Errorf("iP provided to Apply must not be nil") + } + data, err := json.Marshal(iP) + if err != nil { + return nil, err + } + name := iP.Name + if name == nil { + return nil, fmt.Errorf("iP.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ipsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.IP{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IP), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ipaddress.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ipaddress.go new file mode 100644 index 00000000..5bd483c7 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_ipaddress.go @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeIPAddresses implements IPAddressInterface +type FakeIPAddresses struct { + Fake *FakeCoreV1alpha1 +} + +var ipaddressesResource = v1alpha1.SchemeGroupVersion.WithResource("ipaddresses") + +var ipaddressesKind = v1alpha1.SchemeGroupVersion.WithKind("IPAddress") + +// Get takes name of the iPAddress, and returns the corresponding iPAddress object, and an error if there is any. +func (c *FakeIPAddresses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPAddress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(ipaddressesResource, name), &v1alpha1.IPAddress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddress), err +} + +// List takes label and field selectors, and returns the list of IPAddresses that match those selectors. +func (c *FakeIPAddresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(ipaddressesResource, ipaddressesKind, opts), &v1alpha1.IPAddressList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IPAddressList{ListMeta: obj.(*v1alpha1.IPAddressList).ListMeta} + for _, item := range obj.(*v1alpha1.IPAddressList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested iPAddresses. +func (c *FakeIPAddresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(ipaddressesResource, opts)) +} + +// Create takes the representation of a iPAddress and creates it. Returns the server's representation of the iPAddress, and an error, if there is any. +func (c *FakeIPAddresses) Create(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.CreateOptions) (result *v1alpha1.IPAddress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(ipaddressesResource, iPAddress), &v1alpha1.IPAddress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddress), err +} + +// Update takes the representation of a iPAddress and updates it. Returns the server's representation of the iPAddress, and an error, if there is any. +func (c *FakeIPAddresses) Update(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.UpdateOptions) (result *v1alpha1.IPAddress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(ipaddressesResource, iPAddress), &v1alpha1.IPAddress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddress), err +} + +// Delete takes name of the iPAddress and deletes it. Returns an error if one occurs. +func (c *FakeIPAddresses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(ipaddressesResource, name, opts), &v1alpha1.IPAddress{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIPAddresses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(ipaddressesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.IPAddressList{}) + return err +} + +// Patch applies the patch and returns the patched iPAddress. +func (c *FakeIPAddresses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPAddress, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(ipaddressesResource, name, pt, data, subresources...), &v1alpha1.IPAddress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddress), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied iPAddress. +func (c *FakeIPAddresses) Apply(ctx context.Context, iPAddress *corev1alpha1.IPAddressApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IPAddress, err error) { + if iPAddress == nil { + return nil, fmt.Errorf("iPAddress provided to Apply must not be nil") + } + data, err := json.Marshal(iPAddress) + if err != nil { + return nil, err + } + name := iPAddress.Name + if name == nil { + return nil, fmt.Errorf("iPAddress.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(ipaddressesResource, *name, types.ApplyPatchType, data), &v1alpha1.IPAddress{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddress), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancer.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancer.go new file mode 100644 index 00000000..df87031a --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancer.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeLoadBalancers implements LoadBalancerInterface +type FakeLoadBalancers struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var loadbalancersResource = v1alpha1.SchemeGroupVersion.WithResource("loadbalancers") + +var loadbalancersKind = v1alpha1.SchemeGroupVersion.WithKind("LoadBalancer") + +// Get takes name of the loadBalancer, and returns the corresponding loadBalancer object, and an error if there is any. +func (c *FakeLoadBalancers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.LoadBalancer, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(loadbalancersResource, c.ns, name), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// List takes label and field selectors, and returns the list of LoadBalancers that match those selectors. +func (c *FakeLoadBalancers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LoadBalancerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(loadbalancersResource, loadbalancersKind, c.ns, opts), &v1alpha1.LoadBalancerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.LoadBalancerList{ListMeta: obj.(*v1alpha1.LoadBalancerList).ListMeta} + for _, item := range obj.(*v1alpha1.LoadBalancerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested loadBalancers. +func (c *FakeLoadBalancers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(loadbalancersResource, c.ns, opts)) + +} + +// Create takes the representation of a loadBalancer and creates it. Returns the server's representation of the loadBalancer, and an error, if there is any. +func (c *FakeLoadBalancers) Create(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.CreateOptions) (result *v1alpha1.LoadBalancer, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(loadbalancersResource, c.ns, loadBalancer), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// Update takes the representation of a loadBalancer and updates it. Returns the server's representation of the loadBalancer, and an error, if there is any. +func (c *FakeLoadBalancers) Update(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (result *v1alpha1.LoadBalancer, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(loadbalancersResource, c.ns, loadBalancer), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeLoadBalancers) UpdateStatus(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (*v1alpha1.LoadBalancer, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(loadbalancersResource, "status", c.ns, loadBalancer), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// Delete takes name of the loadBalancer and deletes it. Returns an error if one occurs. +func (c *FakeLoadBalancers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(loadbalancersResource, c.ns, name, opts), &v1alpha1.LoadBalancer{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeLoadBalancers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(loadbalancersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.LoadBalancerList{}) + return err +} + +// Patch applies the patch and returns the patched loadBalancer. +func (c *FakeLoadBalancers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancer, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(loadbalancersResource, c.ns, name, pt, data, subresources...), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied loadBalancer. +func (c *FakeLoadBalancers) Apply(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) { + if loadBalancer == nil { + return nil, fmt.Errorf("loadBalancer provided to Apply must not be nil") + } + data, err := json.Marshal(loadBalancer) + if err != nil { + return nil, err + } + name := loadBalancer.Name + if name == nil { + return nil, fmt.Errorf("loadBalancer.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(loadbalancersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeLoadBalancers) ApplyStatus(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) { + if loadBalancer == nil { + return nil, fmt.Errorf("loadBalancer provided to Apply must not be nil") + } + data, err := json.Marshal(loadBalancer) + if err != nil { + return nil, err + } + name := loadBalancer.Name + if name == nil { + return nil, fmt.Errorf("loadBalancer.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(loadbalancersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.LoadBalancer{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancer), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancerrouting.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancerrouting.go new file mode 100644 index 00000000..3c341c21 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_loadbalancerrouting.go @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeLoadBalancerRoutings implements LoadBalancerRoutingInterface +type FakeLoadBalancerRoutings struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var loadbalancerroutingsResource = v1alpha1.SchemeGroupVersion.WithResource("loadbalancerroutings") + +var loadbalancerroutingsKind = v1alpha1.SchemeGroupVersion.WithKind("LoadBalancerRouting") + +// Get takes name of the loadBalancerRouting, and returns the corresponding loadBalancerRouting object, and an error if there is any. +func (c *FakeLoadBalancerRoutings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(loadbalancerroutingsResource, c.ns, name), &v1alpha1.LoadBalancerRouting{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancerRouting), err +} + +// List takes label and field selectors, and returns the list of LoadBalancerRoutings that match those selectors. +func (c *FakeLoadBalancerRoutings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LoadBalancerRoutingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(loadbalancerroutingsResource, loadbalancerroutingsKind, c.ns, opts), &v1alpha1.LoadBalancerRoutingList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.LoadBalancerRoutingList{ListMeta: obj.(*v1alpha1.LoadBalancerRoutingList).ListMeta} + for _, item := range obj.(*v1alpha1.LoadBalancerRoutingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested loadBalancerRoutings. +func (c *FakeLoadBalancerRoutings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(loadbalancerroutingsResource, c.ns, opts)) + +} + +// Create takes the representation of a loadBalancerRouting and creates it. Returns the server's representation of the loadBalancerRouting, and an error, if there is any. +func (c *FakeLoadBalancerRoutings) Create(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.CreateOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(loadbalancerroutingsResource, c.ns, loadBalancerRouting), &v1alpha1.LoadBalancerRouting{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancerRouting), err +} + +// Update takes the representation of a loadBalancerRouting and updates it. Returns the server's representation of the loadBalancerRouting, and an error, if there is any. +func (c *FakeLoadBalancerRoutings) Update(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.UpdateOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(loadbalancerroutingsResource, c.ns, loadBalancerRouting), &v1alpha1.LoadBalancerRouting{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancerRouting), err +} + +// Delete takes name of the loadBalancerRouting and deletes it. Returns an error if one occurs. +func (c *FakeLoadBalancerRoutings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(loadbalancerroutingsResource, c.ns, name, opts), &v1alpha1.LoadBalancerRouting{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeLoadBalancerRoutings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(loadbalancerroutingsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.LoadBalancerRoutingList{}) + return err +} + +// Patch applies the patch and returns the patched loadBalancerRouting. +func (c *FakeLoadBalancerRoutings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancerRouting, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(loadbalancerroutingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.LoadBalancerRouting{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancerRouting), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied loadBalancerRouting. +func (c *FakeLoadBalancerRoutings) Apply(ctx context.Context, loadBalancerRouting *corev1alpha1.LoadBalancerRoutingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + if loadBalancerRouting == nil { + return nil, fmt.Errorf("loadBalancerRouting provided to Apply must not be nil") + } + data, err := json.Marshal(loadBalancerRouting) + if err != nil { + return nil, err + } + name := loadBalancerRouting.Name + if name == nil { + return nil, fmt.Errorf("loadBalancerRouting.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(loadbalancerroutingsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.LoadBalancerRouting{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.LoadBalancerRouting), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgateway.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgateway.go new file mode 100644 index 00000000..f5da95d8 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgateway.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNATGateways implements NATGatewayInterface +type FakeNATGateways struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var natgatewaysResource = v1alpha1.SchemeGroupVersion.WithResource("natgateways") + +var natgatewaysKind = v1alpha1.SchemeGroupVersion.WithKind("NATGateway") + +// Get takes name of the nATGateway, and returns the corresponding nATGateway object, and an error if there is any. +func (c *FakeNATGateways) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATGateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(natgatewaysResource, c.ns, name), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// List takes label and field selectors, and returns the list of NATGateways that match those selectors. +func (c *FakeNATGateways) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATGatewayList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(natgatewaysResource, natgatewaysKind, c.ns, opts), &v1alpha1.NATGatewayList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NATGatewayList{ListMeta: obj.(*v1alpha1.NATGatewayList).ListMeta} + for _, item := range obj.(*v1alpha1.NATGatewayList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested nATGateways. +func (c *FakeNATGateways) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(natgatewaysResource, c.ns, opts)) + +} + +// Create takes the representation of a nATGateway and creates it. Returns the server's representation of the nATGateway, and an error, if there is any. +func (c *FakeNATGateways) Create(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.CreateOptions) (result *v1alpha1.NATGateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(natgatewaysResource, c.ns, nATGateway), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// Update takes the representation of a nATGateway and updates it. Returns the server's representation of the nATGateway, and an error, if there is any. +func (c *FakeNATGateways) Update(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (result *v1alpha1.NATGateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(natgatewaysResource, c.ns, nATGateway), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNATGateways) UpdateStatus(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (*v1alpha1.NATGateway, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(natgatewaysResource, "status", c.ns, nATGateway), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// Delete takes name of the nATGateway and deletes it. Returns an error if one occurs. +func (c *FakeNATGateways) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(natgatewaysResource, c.ns, name, opts), &v1alpha1.NATGateway{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNATGateways) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(natgatewaysResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NATGatewayList{}) + return err +} + +// Patch applies the patch and returns the patched nATGateway. +func (c *FakeNATGateways) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewaysResource, c.ns, name, pt, data, subresources...), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATGateway. +func (c *FakeNATGateways) Apply(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) { + if nATGateway == nil { + return nil, fmt.Errorf("nATGateway provided to Apply must not be nil") + } + data, err := json.Marshal(nATGateway) + if err != nil { + return nil, err + } + name := nATGateway.Name + if name == nil { + return nil, fmt.Errorf("nATGateway.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewaysResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeNATGateways) ApplyStatus(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) { + if nATGateway == nil { + return nil, fmt.Errorf("nATGateway provided to Apply must not be nil") + } + data, err := json.Marshal(nATGateway) + if err != nil { + return nil, err + } + name := nATGateway.Name + if name == nil { + return nil, fmt.Errorf("nATGateway.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewaysResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.NATGateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGateway), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgatewayautoscaler.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgatewayautoscaler.go new file mode 100644 index 00000000..1a367ff8 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_natgatewayautoscaler.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNATGatewayAutoscalers implements NATGatewayAutoscalerInterface +type FakeNATGatewayAutoscalers struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var natgatewayautoscalersResource = v1alpha1.SchemeGroupVersion.WithResource("natgatewayautoscalers") + +var natgatewayautoscalersKind = v1alpha1.SchemeGroupVersion.WithKind("NATGatewayAutoscaler") + +// Get takes name of the nATGatewayAutoscaler, and returns the corresponding nATGatewayAutoscaler object, and an error if there is any. +func (c *FakeNATGatewayAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(natgatewayautoscalersResource, c.ns, name), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// List takes label and field selectors, and returns the list of NATGatewayAutoscalers that match those selectors. +func (c *FakeNATGatewayAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATGatewayAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(natgatewayautoscalersResource, natgatewayautoscalersKind, c.ns, opts), &v1alpha1.NATGatewayAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NATGatewayAutoscalerList{ListMeta: obj.(*v1alpha1.NATGatewayAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha1.NATGatewayAutoscalerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested nATGatewayAutoscalers. +func (c *FakeNATGatewayAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(natgatewayautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a nATGatewayAutoscaler and creates it. Returns the server's representation of the nATGatewayAutoscaler, and an error, if there is any. +func (c *FakeNATGatewayAutoscalers) Create(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.CreateOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(natgatewayautoscalersResource, c.ns, nATGatewayAutoscaler), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// Update takes the representation of a nATGatewayAutoscaler and updates it. Returns the server's representation of the nATGatewayAutoscaler, and an error, if there is any. +func (c *FakeNATGatewayAutoscalers) Update(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(natgatewayautoscalersResource, c.ns, nATGatewayAutoscaler), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNATGatewayAutoscalers) UpdateStatus(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (*v1alpha1.NATGatewayAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(natgatewayautoscalersResource, "status", c.ns, nATGatewayAutoscaler), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// Delete takes name of the nATGatewayAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeNATGatewayAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(natgatewayautoscalersResource, c.ns, name, opts), &v1alpha1.NATGatewayAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNATGatewayAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(natgatewayautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NATGatewayAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched nATGatewayAutoscaler. +func (c *FakeNATGatewayAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGatewayAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewayautoscalersResource, c.ns, name, pt, data, subresources...), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATGatewayAutoscaler. +func (c *FakeNATGatewayAutoscalers) Apply(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + if nATGatewayAutoscaler == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler provided to Apply must not be nil") + } + data, err := json.Marshal(nATGatewayAutoscaler) + if err != nil { + return nil, err + } + name := nATGatewayAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewayautoscalersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeNATGatewayAutoscalers) ApplyStatus(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + if nATGatewayAutoscaler == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler provided to Apply must not be nil") + } + data, err := json.Marshal(nATGatewayAutoscaler) + if err != nil { + return nil, err + } + name := nATGatewayAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(natgatewayautoscalersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.NATGatewayAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATGatewayAutoscaler), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_nattable.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_nattable.go new file mode 100644 index 00000000..be9e19de --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_nattable.go @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNATTables implements NATTableInterface +type FakeNATTables struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var nattablesResource = v1alpha1.SchemeGroupVersion.WithResource("nattables") + +var nattablesKind = v1alpha1.SchemeGroupVersion.WithKind("NATTable") + +// Get takes name of the nATTable, and returns the corresponding nATTable object, and an error if there is any. +func (c *FakeNATTables) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATTable, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(nattablesResource, c.ns, name), &v1alpha1.NATTable{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATTable), err +} + +// List takes label and field selectors, and returns the list of NATTables that match those selectors. +func (c *FakeNATTables) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATTableList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(nattablesResource, nattablesKind, c.ns, opts), &v1alpha1.NATTableList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NATTableList{ListMeta: obj.(*v1alpha1.NATTableList).ListMeta} + for _, item := range obj.(*v1alpha1.NATTableList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested nATTables. +func (c *FakeNATTables) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(nattablesResource, c.ns, opts)) + +} + +// Create takes the representation of a nATTable and creates it. Returns the server's representation of the nATTable, and an error, if there is any. +func (c *FakeNATTables) Create(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.CreateOptions) (result *v1alpha1.NATTable, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(nattablesResource, c.ns, nATTable), &v1alpha1.NATTable{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATTable), err +} + +// Update takes the representation of a nATTable and updates it. Returns the server's representation of the nATTable, and an error, if there is any. +func (c *FakeNATTables) Update(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.UpdateOptions) (result *v1alpha1.NATTable, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(nattablesResource, c.ns, nATTable), &v1alpha1.NATTable{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATTable), err +} + +// Delete takes name of the nATTable and deletes it. Returns an error if one occurs. +func (c *FakeNATTables) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(nattablesResource, c.ns, name, opts), &v1alpha1.NATTable{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNATTables) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(nattablesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NATTableList{}) + return err +} + +// Patch applies the patch and returns the patched nATTable. +func (c *FakeNATTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATTable, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(nattablesResource, c.ns, name, pt, data, subresources...), &v1alpha1.NATTable{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATTable), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATTable. +func (c *FakeNATTables) Apply(ctx context.Context, nATTable *corev1alpha1.NATTableApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATTable, err error) { + if nATTable == nil { + return nil, fmt.Errorf("nATTable provided to Apply must not be nil") + } + data, err := json.Marshal(nATTable) + if err != nil { + return nil, err + } + name := nATTable.Name + if name == nil { + return nil, fmt.Errorf("nATTable.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(nattablesResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.NATTable{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NATTable), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_network.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_network.go new file mode 100644 index 00000000..25eb0401 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_network.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNetworks implements NetworkInterface +type FakeNetworks struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var networksResource = v1alpha1.SchemeGroupVersion.WithResource("networks") + +var networksKind = v1alpha1.SchemeGroupVersion.WithKind("Network") + +// Get takes name of the network, and returns the corresponding network object, and an error if there is any. +func (c *FakeNetworks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Network, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(networksResource, c.ns, name), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// List takes label and field selectors, and returns the list of Networks that match those selectors. +func (c *FakeNetworks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(networksResource, networksKind, c.ns, opts), &v1alpha1.NetworkList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NetworkList{ListMeta: obj.(*v1alpha1.NetworkList).ListMeta} + for _, item := range obj.(*v1alpha1.NetworkList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested networks. +func (c *FakeNetworks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(networksResource, c.ns, opts)) + +} + +// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any. +func (c *FakeNetworks) Create(ctx context.Context, network *v1alpha1.Network, opts v1.CreateOptions) (result *v1alpha1.Network, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(networksResource, c.ns, network), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any. +func (c *FakeNetworks) Update(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (result *v1alpha1.Network, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(networksResource, c.ns, network), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNetworks) UpdateStatus(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (*v1alpha1.Network, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(networksResource, "status", c.ns, network), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// Delete takes name of the network and deletes it. Returns an error if one occurs. +func (c *FakeNetworks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(networksResource, c.ns, name, opts), &v1alpha1.Network{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNetworks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(networksResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NetworkList{}) + return err +} + +// Patch applies the patch and returns the patched network. +func (c *FakeNetworks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Network, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networksResource, c.ns, name, pt, data, subresources...), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied network. +func (c *FakeNetworks) Apply(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) { + if network == nil { + return nil, fmt.Errorf("network provided to Apply must not be nil") + } + data, err := json.Marshal(network) + if err != nil { + return nil, err + } + name := network.Name + if name == nil { + return nil, fmt.Errorf("network.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networksResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeNetworks) ApplyStatus(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) { + if network == nil { + return nil, fmt.Errorf("network provided to Apply must not be nil") + } + data, err := json.Marshal(network) + if err != nil { + return nil, err + } + name := network.Name + if name == nil { + return nil, fmt.Errorf("network.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networksResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Network{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Network), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkid.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkid.go new file mode 100644 index 00000000..b3e3f87d --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkid.go @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNetworkIDs implements NetworkIDInterface +type FakeNetworkIDs struct { + Fake *FakeCoreV1alpha1 +} + +var networkidsResource = v1alpha1.SchemeGroupVersion.WithResource("networkids") + +var networkidsKind = v1alpha1.SchemeGroupVersion.WithKind("NetworkID") + +// Get takes name of the networkID, and returns the corresponding networkID object, and an error if there is any. +func (c *FakeNetworkIDs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkID, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(networkidsResource, name), &v1alpha1.NetworkID{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkID), err +} + +// List takes label and field selectors, and returns the list of NetworkIDs that match those selectors. +func (c *FakeNetworkIDs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkIDList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(networkidsResource, networkidsKind, opts), &v1alpha1.NetworkIDList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NetworkIDList{ListMeta: obj.(*v1alpha1.NetworkIDList).ListMeta} + for _, item := range obj.(*v1alpha1.NetworkIDList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested networkIDs. +func (c *FakeNetworkIDs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(networkidsResource, opts)) +} + +// Create takes the representation of a networkID and creates it. Returns the server's representation of the networkID, and an error, if there is any. +func (c *FakeNetworkIDs) Create(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.CreateOptions) (result *v1alpha1.NetworkID, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(networkidsResource, networkID), &v1alpha1.NetworkID{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkID), err +} + +// Update takes the representation of a networkID and updates it. Returns the server's representation of the networkID, and an error, if there is any. +func (c *FakeNetworkIDs) Update(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.UpdateOptions) (result *v1alpha1.NetworkID, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(networkidsResource, networkID), &v1alpha1.NetworkID{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkID), err +} + +// Delete takes name of the networkID and deletes it. Returns an error if one occurs. +func (c *FakeNetworkIDs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(networkidsResource, name, opts), &v1alpha1.NetworkID{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNetworkIDs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(networkidsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NetworkIDList{}) + return err +} + +// Patch applies the patch and returns the patched networkID. +func (c *FakeNetworkIDs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkID, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(networkidsResource, name, pt, data, subresources...), &v1alpha1.NetworkID{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkID), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied networkID. +func (c *FakeNetworkIDs) Apply(ctx context.Context, networkID *corev1alpha1.NetworkIDApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkID, err error) { + if networkID == nil { + return nil, fmt.Errorf("networkID provided to Apply must not be nil") + } + data, err := json.Marshal(networkID) + if err != nil { + return nil, err + } + name := networkID.Name + if name == nil { + return nil, fmt.Errorf("networkID.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(networkidsResource, *name, types.ApplyPatchType, data), &v1alpha1.NetworkID{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkID), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkinterface.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkinterface.go new file mode 100644 index 00000000..f42caff5 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_networkinterface.go @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNetworkInterfaces implements NetworkInterfaceInterface +type FakeNetworkInterfaces struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var networkinterfacesResource = v1alpha1.SchemeGroupVersion.WithResource("networkinterfaces") + +var networkinterfacesKind = v1alpha1.SchemeGroupVersion.WithKind("NetworkInterface") + +// Get takes name of the networkInterface, and returns the corresponding networkInterface object, and an error if there is any. +func (c *FakeNetworkInterfaces) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkInterface, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(networkinterfacesResource, c.ns, name), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// List takes label and field selectors, and returns the list of NetworkInterfaces that match those selectors. +func (c *FakeNetworkInterfaces) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkInterfaceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(networkinterfacesResource, networkinterfacesKind, c.ns, opts), &v1alpha1.NetworkInterfaceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NetworkInterfaceList{ListMeta: obj.(*v1alpha1.NetworkInterfaceList).ListMeta} + for _, item := range obj.(*v1alpha1.NetworkInterfaceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested networkInterfaces. +func (c *FakeNetworkInterfaces) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(networkinterfacesResource, c.ns, opts)) + +} + +// Create takes the representation of a networkInterface and creates it. Returns the server's representation of the networkInterface, and an error, if there is any. +func (c *FakeNetworkInterfaces) Create(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.CreateOptions) (result *v1alpha1.NetworkInterface, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(networkinterfacesResource, c.ns, networkInterface), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// Update takes the representation of a networkInterface and updates it. Returns the server's representation of the networkInterface, and an error, if there is any. +func (c *FakeNetworkInterfaces) Update(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (result *v1alpha1.NetworkInterface, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(networkinterfacesResource, c.ns, networkInterface), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNetworkInterfaces) UpdateStatus(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (*v1alpha1.NetworkInterface, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(networkinterfacesResource, "status", c.ns, networkInterface), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// Delete takes name of the networkInterface and deletes it. Returns an error if one occurs. +func (c *FakeNetworkInterfaces) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(networkinterfacesResource, c.ns, name, opts), &v1alpha1.NetworkInterface{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNetworkInterfaces) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(networkinterfacesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NetworkInterfaceList{}) + return err +} + +// Patch applies the patch and returns the patched networkInterface. +func (c *FakeNetworkInterfaces) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkInterface, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networkinterfacesResource, c.ns, name, pt, data, subresources...), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied networkInterface. +func (c *FakeNetworkInterfaces) Apply(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) { + if networkInterface == nil { + return nil, fmt.Errorf("networkInterface provided to Apply must not be nil") + } + data, err := json.Marshal(networkInterface) + if err != nil { + return nil, err + } + name := networkInterface.Name + if name == nil { + return nil, fmt.Errorf("networkInterface.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networkinterfacesResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeNetworkInterfaces) ApplyStatus(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) { + if networkInterface == nil { + return nil, fmt.Errorf("networkInterface provided to Apply must not be nil") + } + data, err := json.Marshal(networkInterface) + if err != nil { + return nil, err + } + name := networkInterface.Name + if name == nil { + return nil, fmt.Errorf("networkInterface.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(networkinterfacesResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.NetworkInterface{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NetworkInterface), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_node.go b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_node.go new file mode 100644 index 00000000..b9631d4c --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/fake/fake_node.go @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNodes implements NodeInterface +type FakeNodes struct { + Fake *FakeCoreV1alpha1 +} + +var nodesResource = v1alpha1.SchemeGroupVersion.WithResource("nodes") + +var nodesKind = v1alpha1.SchemeGroupVersion.WithKind("Node") + +// Get takes name of the node, and returns the corresponding node object, and an error if there is any. +func (c *FakeNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Node, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(nodesResource, name), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// List takes label and field selectors, and returns the list of Nodes that match those selectors. +func (c *FakeNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(nodesResource, nodesKind, opts), &v1alpha1.NodeList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NodeList{ListMeta: obj.(*v1alpha1.NodeList).ListMeta} + for _, item := range obj.(*v1alpha1.NodeList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested nodes. +func (c *FakeNodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(nodesResource, opts)) +} + +// Create takes the representation of a node and creates it. Returns the server's representation of the node, and an error, if there is any. +func (c *FakeNodes) Create(ctx context.Context, node *v1alpha1.Node, opts v1.CreateOptions) (result *v1alpha1.Node, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(nodesResource, node), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// Update takes the representation of a node and updates it. Returns the server's representation of the node, and an error, if there is any. +func (c *FakeNodes) Update(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (result *v1alpha1.Node, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(nodesResource, node), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNodes) UpdateStatus(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (*v1alpha1.Node, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(nodesResource, "status", node), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// Delete takes name of the node and deletes it. Returns an error if one occurs. +func (c *FakeNodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(nodesResource, name, opts), &v1alpha1.Node{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(nodesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NodeList{}) + return err +} + +// Patch applies the patch and returns the patched node. +func (c *FakeNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Node, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodesResource, name, pt, data, subresources...), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied node. +func (c *FakeNodes) Apply(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) { + if node == nil { + return nil, fmt.Errorf("node provided to Apply must not be nil") + } + data, err := json.Marshal(node) + if err != nil { + return nil, err + } + name := node.Name + if name == nil { + return nil, fmt.Errorf("node.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodesResource, *name, types.ApplyPatchType, data), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeNodes) ApplyStatus(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) { + if node == nil { + return nil, fmt.Errorf("node provided to Apply must not be nil") + } + data, err := json.Marshal(node) + if err != nil { + return nil, err + } + name := node.Name + if name == nil { + return nil, fmt.Errorf("node.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodesResource, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Node{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Node), err +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/generated_expansion.go b/client-go/onmetalapinet/typed/core/v1alpha1/generated_expansion.go new file mode 100644 index 00000000..0970c99b --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/generated_expansion.go @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +type DaemonSetExpansion interface{} + +type IPExpansion interface{} + +type IPAddressExpansion interface{} + +type InstanceExpansion interface{} + +type LoadBalancerExpansion interface{} + +type LoadBalancerRoutingExpansion interface{} + +type NATGatewayExpansion interface{} + +type NATGatewayAutoscalerExpansion interface{} + +type NATTableExpansion interface{} + +type NetworkExpansion interface{} + +type NetworkIDExpansion interface{} + +type NetworkInterfaceExpansion interface{} + +type NodeExpansion interface{} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/instance.go b/client-go/onmetalapinet/typed/core/v1alpha1/instance.go new file mode 100644 index 00000000..39f5e48d --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/instance.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// InstancesGetter has a method to return a InstanceInterface. +// A group's client should implement this interface. +type InstancesGetter interface { + Instances(namespace string) InstanceInterface +} + +// InstanceInterface has methods to work with Instance resources. +type InstanceInterface interface { + Create(ctx context.Context, instance *v1alpha1.Instance, opts v1.CreateOptions) (*v1alpha1.Instance, error) + Update(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (*v1alpha1.Instance, error) + UpdateStatus(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (*v1alpha1.Instance, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Instance, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.InstanceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Instance, err error) + Apply(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) + ApplyStatus(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) + InstanceExpansion +} + +// instances implements InstanceInterface +type instances struct { + client rest.Interface + ns string +} + +// newInstances returns a Instances +func newInstances(c *CoreV1alpha1Client, namespace string) *instances { + return &instances{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the instance, and returns the corresponding instance object, and an error if there is any. +func (c *instances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Instance, err error) { + result = &v1alpha1.Instance{} + err = c.client.Get(). + Namespace(c.ns). + Resource("instances"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Instances that match those selectors. +func (c *instances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstanceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.InstanceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("instances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested instances. +func (c *instances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("instances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a instance and creates it. Returns the server's representation of the instance, and an error, if there is any. +func (c *instances) Create(ctx context.Context, instance *v1alpha1.Instance, opts v1.CreateOptions) (result *v1alpha1.Instance, err error) { + result = &v1alpha1.Instance{} + err = c.client.Post(). + Namespace(c.ns). + Resource("instances"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instance). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a instance and updates it. Returns the server's representation of the instance, and an error, if there is any. +func (c *instances) Update(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (result *v1alpha1.Instance, err error) { + result = &v1alpha1.Instance{} + err = c.client.Put(). + Namespace(c.ns). + Resource("instances"). + Name(instance.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instance). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *instances) UpdateStatus(ctx context.Context, instance *v1alpha1.Instance, opts v1.UpdateOptions) (result *v1alpha1.Instance, err error) { + result = &v1alpha1.Instance{} + err = c.client.Put(). + Namespace(c.ns). + Resource("instances"). + Name(instance.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instance). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the instance and deletes it. Returns an error if one occurs. +func (c *instances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("instances"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *instances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("instances"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched instance. +func (c *instances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Instance, err error) { + result = &v1alpha1.Instance{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("instances"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied instance. +func (c *instances) Apply(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) { + if instance == nil { + return nil, fmt.Errorf("instance provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(instance) + if err != nil { + return nil, err + } + name := instance.Name + if name == nil { + return nil, fmt.Errorf("instance.Name must be provided to Apply") + } + result = &v1alpha1.Instance{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("instances"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *instances) ApplyStatus(ctx context.Context, instance *corev1alpha1.InstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instance, err error) { + if instance == nil { + return nil, fmt.Errorf("instance provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(instance) + if err != nil { + return nil, err + } + + name := instance.Name + if name == nil { + return nil, fmt.Errorf("instance.Name must be provided to Apply") + } + + result = &v1alpha1.Instance{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("instances"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/ip.go b/client-go/onmetalapinet/typed/core/v1alpha1/ip.go new file mode 100644 index 00000000..82a556f7 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/ip.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// IPsGetter has a method to return a IPInterface. +// A group's client should implement this interface. +type IPsGetter interface { + IPs(namespace string) IPInterface +} + +// IPInterface has methods to work with IP resources. +type IPInterface interface { + Create(ctx context.Context, iP *v1alpha1.IP, opts v1.CreateOptions) (*v1alpha1.IP, error) + Update(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (*v1alpha1.IP, error) + UpdateStatus(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (*v1alpha1.IP, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.IP, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IP, err error) + Apply(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) + ApplyStatus(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) + IPExpansion +} + +// iPs implements IPInterface +type iPs struct { + client rest.Interface + ns string +} + +// newIPs returns a IPs +func newIPs(c *CoreV1alpha1Client, namespace string) *iPs { + return &iPs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the iP, and returns the corresponding iP object, and an error if there is any. +func (c *iPs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IP, err error) { + result = &v1alpha1.IP{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IPs that match those selectors. +func (c *iPs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IPList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iPs. +func (c *iPs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iP and creates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *iPs) Create(ctx context.Context, iP *v1alpha1.IP, opts v1.CreateOptions) (result *v1alpha1.IP, err error) { + result = &v1alpha1.IP{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iP). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iP and updates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *iPs) Update(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (result *v1alpha1.IP, err error) { + result = &v1alpha1.IP{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ips"). + Name(iP.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iP). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *iPs) UpdateStatus(ctx context.Context, iP *v1alpha1.IP, opts v1.UpdateOptions) (result *v1alpha1.IP, err error) { + result = &v1alpha1.IP{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ips"). + Name(iP.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iP). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iP and deletes it. Returns an error if one occurs. +func (c *iPs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iPs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("ips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iP. +func (c *iPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IP, err error) { + result = &v1alpha1.IP{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied iP. +func (c *iPs) Apply(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) { + if iP == nil { + return nil, fmt.Errorf("iP provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(iP) + if err != nil { + return nil, err + } + name := iP.Name + if name == nil { + return nil, fmt.Errorf("iP.Name must be provided to Apply") + } + result = &v1alpha1.IP{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("ips"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *iPs) ApplyStatus(ctx context.Context, iP *corev1alpha1.IPApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IP, err error) { + if iP == nil { + return nil, fmt.Errorf("iP provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(iP) + if err != nil { + return nil, err + } + + name := iP.Name + if name == nil { + return nil, fmt.Errorf("iP.Name must be provided to Apply") + } + + result = &v1alpha1.IP{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("ips"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/ipaddress.go b/client-go/onmetalapinet/typed/core/v1alpha1/ipaddress.go new file mode 100644 index 00000000..0a811a8d --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/ipaddress.go @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// IPAddressesGetter has a method to return a IPAddressInterface. +// A group's client should implement this interface. +type IPAddressesGetter interface { + IPAddresses() IPAddressInterface +} + +// IPAddressInterface has methods to work with IPAddress resources. +type IPAddressInterface interface { + Create(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.CreateOptions) (*v1alpha1.IPAddress, error) + Update(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.UpdateOptions) (*v1alpha1.IPAddress, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.IPAddress, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPAddressList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPAddress, err error) + Apply(ctx context.Context, iPAddress *corev1alpha1.IPAddressApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IPAddress, err error) + IPAddressExpansion +} + +// iPAddresses implements IPAddressInterface +type iPAddresses struct { + client rest.Interface +} + +// newIPAddresses returns a IPAddresses +func newIPAddresses(c *CoreV1alpha1Client) *iPAddresses { + return &iPAddresses{ + client: c.RESTClient(), + } +} + +// Get takes name of the iPAddress, and returns the corresponding iPAddress object, and an error if there is any. +func (c *iPAddresses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPAddress, err error) { + result = &v1alpha1.IPAddress{} + err = c.client.Get(). + Resource("ipaddresses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IPAddresses that match those selectors. +func (c *iPAddresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IPAddressList{} + err = c.client.Get(). + Resource("ipaddresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iPAddresses. +func (c *iPAddresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("ipaddresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iPAddress and creates it. Returns the server's representation of the iPAddress, and an error, if there is any. +func (c *iPAddresses) Create(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.CreateOptions) (result *v1alpha1.IPAddress, err error) { + result = &v1alpha1.IPAddress{} + err = c.client.Post(). + Resource("ipaddresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPAddress). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iPAddress and updates it. Returns the server's representation of the iPAddress, and an error, if there is any. +func (c *iPAddresses) Update(ctx context.Context, iPAddress *v1alpha1.IPAddress, opts v1.UpdateOptions) (result *v1alpha1.IPAddress, err error) { + result = &v1alpha1.IPAddress{} + err = c.client.Put(). + Resource("ipaddresses"). + Name(iPAddress.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPAddress). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iPAddress and deletes it. Returns an error if one occurs. +func (c *iPAddresses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("ipaddresses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iPAddresses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("ipaddresses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iPAddress. +func (c *iPAddresses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPAddress, err error) { + result = &v1alpha1.IPAddress{} + err = c.client.Patch(pt). + Resource("ipaddresses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied iPAddress. +func (c *iPAddresses) Apply(ctx context.Context, iPAddress *corev1alpha1.IPAddressApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.IPAddress, err error) { + if iPAddress == nil { + return nil, fmt.Errorf("iPAddress provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(iPAddress) + if err != nil { + return nil, err + } + name := iPAddress.Name + if name == nil { + return nil, fmt.Errorf("iPAddress.Name must be provided to Apply") + } + result = &v1alpha1.IPAddress{} + err = c.client.Patch(types.ApplyPatchType). + Resource("ipaddresses"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancer.go b/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancer.go new file mode 100644 index 00000000..5efda532 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancer.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// LoadBalancersGetter has a method to return a LoadBalancerInterface. +// A group's client should implement this interface. +type LoadBalancersGetter interface { + LoadBalancers(namespace string) LoadBalancerInterface +} + +// LoadBalancerInterface has methods to work with LoadBalancer resources. +type LoadBalancerInterface interface { + Create(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.CreateOptions) (*v1alpha1.LoadBalancer, error) + Update(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (*v1alpha1.LoadBalancer, error) + UpdateStatus(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (*v1alpha1.LoadBalancer, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.LoadBalancer, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.LoadBalancerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancer, err error) + Apply(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) + ApplyStatus(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) + LoadBalancerExpansion +} + +// loadBalancers implements LoadBalancerInterface +type loadBalancers struct { + client rest.Interface + ns string +} + +// newLoadBalancers returns a LoadBalancers +func newLoadBalancers(c *CoreV1alpha1Client, namespace string) *loadBalancers { + return &loadBalancers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the loadBalancer, and returns the corresponding loadBalancer object, and an error if there is any. +func (c *loadBalancers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.LoadBalancer, err error) { + result = &v1alpha1.LoadBalancer{} + err = c.client.Get(). + Namespace(c.ns). + Resource("loadbalancers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of LoadBalancers that match those selectors. +func (c *loadBalancers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LoadBalancerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.LoadBalancerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("loadbalancers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested loadBalancers. +func (c *loadBalancers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("loadbalancers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a loadBalancer and creates it. Returns the server's representation of the loadBalancer, and an error, if there is any. +func (c *loadBalancers) Create(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.CreateOptions) (result *v1alpha1.LoadBalancer, err error) { + result = &v1alpha1.LoadBalancer{} + err = c.client.Post(). + Namespace(c.ns). + Resource("loadbalancers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(loadBalancer). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a loadBalancer and updates it. Returns the server's representation of the loadBalancer, and an error, if there is any. +func (c *loadBalancers) Update(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (result *v1alpha1.LoadBalancer, err error) { + result = &v1alpha1.LoadBalancer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("loadbalancers"). + Name(loadBalancer.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(loadBalancer). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *loadBalancers) UpdateStatus(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer, opts v1.UpdateOptions) (result *v1alpha1.LoadBalancer, err error) { + result = &v1alpha1.LoadBalancer{} + err = c.client.Put(). + Namespace(c.ns). + Resource("loadbalancers"). + Name(loadBalancer.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(loadBalancer). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the loadBalancer and deletes it. Returns an error if one occurs. +func (c *loadBalancers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("loadbalancers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *loadBalancers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("loadbalancers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched loadBalancer. +func (c *loadBalancers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancer, err error) { + result = &v1alpha1.LoadBalancer{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("loadbalancers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied loadBalancer. +func (c *loadBalancers) Apply(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) { + if loadBalancer == nil { + return nil, fmt.Errorf("loadBalancer provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(loadBalancer) + if err != nil { + return nil, err + } + name := loadBalancer.Name + if name == nil { + return nil, fmt.Errorf("loadBalancer.Name must be provided to Apply") + } + result = &v1alpha1.LoadBalancer{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("loadbalancers"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *loadBalancers) ApplyStatus(ctx context.Context, loadBalancer *corev1alpha1.LoadBalancerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancer, err error) { + if loadBalancer == nil { + return nil, fmt.Errorf("loadBalancer provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(loadBalancer) + if err != nil { + return nil, err + } + + name := loadBalancer.Name + if name == nil { + return nil, fmt.Errorf("loadBalancer.Name must be provided to Apply") + } + + result = &v1alpha1.LoadBalancer{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("loadbalancers"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancerrouting.go b/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancerrouting.go new file mode 100644 index 00000000..7e2c55b2 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/loadbalancerrouting.go @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// LoadBalancerRoutingsGetter has a method to return a LoadBalancerRoutingInterface. +// A group's client should implement this interface. +type LoadBalancerRoutingsGetter interface { + LoadBalancerRoutings(namespace string) LoadBalancerRoutingInterface +} + +// LoadBalancerRoutingInterface has methods to work with LoadBalancerRouting resources. +type LoadBalancerRoutingInterface interface { + Create(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.CreateOptions) (*v1alpha1.LoadBalancerRouting, error) + Update(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.UpdateOptions) (*v1alpha1.LoadBalancerRouting, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.LoadBalancerRouting, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.LoadBalancerRoutingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancerRouting, err error) + Apply(ctx context.Context, loadBalancerRouting *corev1alpha1.LoadBalancerRoutingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancerRouting, err error) + LoadBalancerRoutingExpansion +} + +// loadBalancerRoutings implements LoadBalancerRoutingInterface +type loadBalancerRoutings struct { + client rest.Interface + ns string +} + +// newLoadBalancerRoutings returns a LoadBalancerRoutings +func newLoadBalancerRoutings(c *CoreV1alpha1Client, namespace string) *loadBalancerRoutings { + return &loadBalancerRoutings{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the loadBalancerRouting, and returns the corresponding loadBalancerRouting object, and an error if there is any. +func (c *loadBalancerRoutings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + result = &v1alpha1.LoadBalancerRouting{} + err = c.client.Get(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of LoadBalancerRoutings that match those selectors. +func (c *loadBalancerRoutings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LoadBalancerRoutingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.LoadBalancerRoutingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested loadBalancerRoutings. +func (c *loadBalancerRoutings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a loadBalancerRouting and creates it. Returns the server's representation of the loadBalancerRouting, and an error, if there is any. +func (c *loadBalancerRoutings) Create(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.CreateOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + result = &v1alpha1.LoadBalancerRouting{} + err = c.client.Post(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(loadBalancerRouting). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a loadBalancerRouting and updates it. Returns the server's representation of the loadBalancerRouting, and an error, if there is any. +func (c *loadBalancerRoutings) Update(ctx context.Context, loadBalancerRouting *v1alpha1.LoadBalancerRouting, opts v1.UpdateOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + result = &v1alpha1.LoadBalancerRouting{} + err = c.client.Put(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + Name(loadBalancerRouting.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(loadBalancerRouting). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the loadBalancerRouting and deletes it. Returns an error if one occurs. +func (c *loadBalancerRoutings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *loadBalancerRoutings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("loadbalancerroutings"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched loadBalancerRouting. +func (c *loadBalancerRoutings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LoadBalancerRouting, err error) { + result = &v1alpha1.LoadBalancerRouting{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("loadbalancerroutings"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied loadBalancerRouting. +func (c *loadBalancerRoutings) Apply(ctx context.Context, loadBalancerRouting *corev1alpha1.LoadBalancerRoutingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LoadBalancerRouting, err error) { + if loadBalancerRouting == nil { + return nil, fmt.Errorf("loadBalancerRouting provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(loadBalancerRouting) + if err != nil { + return nil, err + } + name := loadBalancerRouting.Name + if name == nil { + return nil, fmt.Errorf("loadBalancerRouting.Name must be provided to Apply") + } + result = &v1alpha1.LoadBalancerRouting{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("loadbalancerroutings"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/natgateway.go b/client-go/onmetalapinet/typed/core/v1alpha1/natgateway.go new file mode 100644 index 00000000..1a24eafe --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/natgateway.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NATGatewaysGetter has a method to return a NATGatewayInterface. +// A group's client should implement this interface. +type NATGatewaysGetter interface { + NATGateways(namespace string) NATGatewayInterface +} + +// NATGatewayInterface has methods to work with NATGateway resources. +type NATGatewayInterface interface { + Create(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.CreateOptions) (*v1alpha1.NATGateway, error) + Update(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (*v1alpha1.NATGateway, error) + UpdateStatus(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (*v1alpha1.NATGateway, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NATGateway, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NATGatewayList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGateway, err error) + Apply(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) + ApplyStatus(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) + NATGatewayExpansion +} + +// nATGateways implements NATGatewayInterface +type nATGateways struct { + client rest.Interface + ns string +} + +// newNATGateways returns a NATGateways +func newNATGateways(c *CoreV1alpha1Client, namespace string) *nATGateways { + return &nATGateways{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the nATGateway, and returns the corresponding nATGateway object, and an error if there is any. +func (c *nATGateways) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATGateway, err error) { + result = &v1alpha1.NATGateway{} + err = c.client.Get(). + Namespace(c.ns). + Resource("natgateways"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NATGateways that match those selectors. +func (c *nATGateways) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATGatewayList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NATGatewayList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("natgateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nATGateways. +func (c *nATGateways) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("natgateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nATGateway and creates it. Returns the server's representation of the nATGateway, and an error, if there is any. +func (c *nATGateways) Create(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.CreateOptions) (result *v1alpha1.NATGateway, err error) { + result = &v1alpha1.NATGateway{} + err = c.client.Post(). + Namespace(c.ns). + Resource("natgateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGateway). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nATGateway and updates it. Returns the server's representation of the nATGateway, and an error, if there is any. +func (c *nATGateways) Update(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (result *v1alpha1.NATGateway, err error) { + result = &v1alpha1.NATGateway{} + err = c.client.Put(). + Namespace(c.ns). + Resource("natgateways"). + Name(nATGateway.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGateway). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *nATGateways) UpdateStatus(ctx context.Context, nATGateway *v1alpha1.NATGateway, opts v1.UpdateOptions) (result *v1alpha1.NATGateway, err error) { + result = &v1alpha1.NATGateway{} + err = c.client.Put(). + Namespace(c.ns). + Resource("natgateways"). + Name(nATGateway.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGateway). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nATGateway and deletes it. Returns an error if one occurs. +func (c *nATGateways) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("natgateways"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nATGateways) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("natgateways"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nATGateway. +func (c *nATGateways) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGateway, err error) { + result = &v1alpha1.NATGateway{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("natgateways"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATGateway. +func (c *nATGateways) Apply(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) { + if nATGateway == nil { + return nil, fmt.Errorf("nATGateway provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(nATGateway) + if err != nil { + return nil, err + } + name := nATGateway.Name + if name == nil { + return nil, fmt.Errorf("nATGateway.Name must be provided to Apply") + } + result = &v1alpha1.NATGateway{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("natgateways"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *nATGateways) ApplyStatus(ctx context.Context, nATGateway *corev1alpha1.NATGatewayApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGateway, err error) { + if nATGateway == nil { + return nil, fmt.Errorf("nATGateway provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(nATGateway) + if err != nil { + return nil, err + } + + name := nATGateway.Name + if name == nil { + return nil, fmt.Errorf("nATGateway.Name must be provided to Apply") + } + + result = &v1alpha1.NATGateway{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("natgateways"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/natgatewayautoscaler.go b/client-go/onmetalapinet/typed/core/v1alpha1/natgatewayautoscaler.go new file mode 100644 index 00000000..97f4bca4 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/natgatewayautoscaler.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NATGatewayAutoscalersGetter has a method to return a NATGatewayAutoscalerInterface. +// A group's client should implement this interface. +type NATGatewayAutoscalersGetter interface { + NATGatewayAutoscalers(namespace string) NATGatewayAutoscalerInterface +} + +// NATGatewayAutoscalerInterface has methods to work with NATGatewayAutoscaler resources. +type NATGatewayAutoscalerInterface interface { + Create(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.CreateOptions) (*v1alpha1.NATGatewayAutoscaler, error) + Update(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (*v1alpha1.NATGatewayAutoscaler, error) + UpdateStatus(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (*v1alpha1.NATGatewayAutoscaler, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NATGatewayAutoscaler, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NATGatewayAutoscalerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGatewayAutoscaler, err error) + Apply(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) + ApplyStatus(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) + NATGatewayAutoscalerExpansion +} + +// nATGatewayAutoscalers implements NATGatewayAutoscalerInterface +type nATGatewayAutoscalers struct { + client rest.Interface + ns string +} + +// newNATGatewayAutoscalers returns a NATGatewayAutoscalers +func newNATGatewayAutoscalers(c *CoreV1alpha1Client, namespace string) *nATGatewayAutoscalers { + return &nATGatewayAutoscalers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the nATGatewayAutoscaler, and returns the corresponding nATGatewayAutoscaler object, and an error if there is any. +func (c *nATGatewayAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Get(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NATGatewayAutoscalers that match those selectors. +func (c *nATGatewayAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATGatewayAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NATGatewayAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nATGatewayAutoscalers. +func (c *nATGatewayAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nATGatewayAutoscaler and creates it. Returns the server's representation of the nATGatewayAutoscaler, and an error, if there is any. +func (c *nATGatewayAutoscalers) Create(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.CreateOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Post(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGatewayAutoscaler). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nATGatewayAutoscaler and updates it. Returns the server's representation of the nATGatewayAutoscaler, and an error, if there is any. +func (c *nATGatewayAutoscalers) Update(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(nATGatewayAutoscaler.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGatewayAutoscaler). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *nATGatewayAutoscalers) UpdateStatus(ctx context.Context, nATGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(nATGatewayAutoscaler.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATGatewayAutoscaler). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nATGatewayAutoscaler and deletes it. Returns an error if one occurs. +func (c *nATGatewayAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nATGatewayAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nATGatewayAutoscaler. +func (c *nATGatewayAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATGatewayAutoscaler, err error) { + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATGatewayAutoscaler. +func (c *nATGatewayAutoscalers) Apply(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + if nATGatewayAutoscaler == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(nATGatewayAutoscaler) + if err != nil { + return nil, err + } + name := nATGatewayAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler.Name must be provided to Apply") + } + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *nATGatewayAutoscalers) ApplyStatus(ctx context.Context, nATGatewayAutoscaler *corev1alpha1.NATGatewayAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATGatewayAutoscaler, err error) { + if nATGatewayAutoscaler == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(nATGatewayAutoscaler) + if err != nil { + return nil, err + } + + name := nATGatewayAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("nATGatewayAutoscaler.Name must be provided to Apply") + } + + result = &v1alpha1.NATGatewayAutoscaler{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("natgatewayautoscalers"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/nattable.go b/client-go/onmetalapinet/typed/core/v1alpha1/nattable.go new file mode 100644 index 00000000..8ec39253 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/nattable.go @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NATTablesGetter has a method to return a NATTableInterface. +// A group's client should implement this interface. +type NATTablesGetter interface { + NATTables(namespace string) NATTableInterface +} + +// NATTableInterface has methods to work with NATTable resources. +type NATTableInterface interface { + Create(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.CreateOptions) (*v1alpha1.NATTable, error) + Update(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.UpdateOptions) (*v1alpha1.NATTable, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NATTable, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NATTableList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATTable, err error) + Apply(ctx context.Context, nATTable *corev1alpha1.NATTableApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATTable, err error) + NATTableExpansion +} + +// nATTables implements NATTableInterface +type nATTables struct { + client rest.Interface + ns string +} + +// newNATTables returns a NATTables +func newNATTables(c *CoreV1alpha1Client, namespace string) *nATTables { + return &nATTables{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the nATTable, and returns the corresponding nATTable object, and an error if there is any. +func (c *nATTables) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NATTable, err error) { + result = &v1alpha1.NATTable{} + err = c.client.Get(). + Namespace(c.ns). + Resource("nattables"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NATTables that match those selectors. +func (c *nATTables) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NATTableList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NATTableList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("nattables"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nATTables. +func (c *nATTables) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("nattables"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nATTable and creates it. Returns the server's representation of the nATTable, and an error, if there is any. +func (c *nATTables) Create(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.CreateOptions) (result *v1alpha1.NATTable, err error) { + result = &v1alpha1.NATTable{} + err = c.client.Post(). + Namespace(c.ns). + Resource("nattables"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATTable). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nATTable and updates it. Returns the server's representation of the nATTable, and an error, if there is any. +func (c *nATTables) Update(ctx context.Context, nATTable *v1alpha1.NATTable, opts v1.UpdateOptions) (result *v1alpha1.NATTable, err error) { + result = &v1alpha1.NATTable{} + err = c.client.Put(). + Namespace(c.ns). + Resource("nattables"). + Name(nATTable.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nATTable). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nATTable and deletes it. Returns an error if one occurs. +func (c *nATTables) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("nattables"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nATTables) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("nattables"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nATTable. +func (c *nATTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NATTable, err error) { + result = &v1alpha1.NATTable{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("nattables"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied nATTable. +func (c *nATTables) Apply(ctx context.Context, nATTable *corev1alpha1.NATTableApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NATTable, err error) { + if nATTable == nil { + return nil, fmt.Errorf("nATTable provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(nATTable) + if err != nil { + return nil, err + } + name := nATTable.Name + if name == nil { + return nil, fmt.Errorf("nATTable.Name must be provided to Apply") + } + result = &v1alpha1.NATTable{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("nattables"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/network.go b/client-go/onmetalapinet/typed/core/v1alpha1/network.go new file mode 100644 index 00000000..28ca5248 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/network.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NetworksGetter has a method to return a NetworkInterface. +// A group's client should implement this interface. +type NetworksGetter interface { + Networks(namespace string) NetworkInterface +} + +// NetworkInterface has methods to work with Network resources. +type NetworkInterface interface { + Create(ctx context.Context, network *v1alpha1.Network, opts v1.CreateOptions) (*v1alpha1.Network, error) + Update(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (*v1alpha1.Network, error) + UpdateStatus(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (*v1alpha1.Network, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Network, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NetworkList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Network, err error) + Apply(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) + ApplyStatus(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) + NetworkExpansion +} + +// networks implements NetworkInterface +type networks struct { + client rest.Interface + ns string +} + +// newNetworks returns a Networks +func newNetworks(c *CoreV1alpha1Client, namespace string) *networks { + return &networks{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the network, and returns the corresponding network object, and an error if there is any. +func (c *networks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Network, err error) { + result = &v1alpha1.Network{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networks"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Networks that match those selectors. +func (c *networks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NetworkList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested networks. +func (c *networks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any. +func (c *networks) Create(ctx context.Context, network *v1alpha1.Network, opts v1.CreateOptions) (result *v1alpha1.Network, err error) { + result = &v1alpha1.Network{} + err = c.client.Post(). + Namespace(c.ns). + Resource("networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(network). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any. +func (c *networks) Update(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (result *v1alpha1.Network, err error) { + result = &v1alpha1.Network{} + err = c.client.Put(). + Namespace(c.ns). + Resource("networks"). + Name(network.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(network). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *networks) UpdateStatus(ctx context.Context, network *v1alpha1.Network, opts v1.UpdateOptions) (result *v1alpha1.Network, err error) { + result = &v1alpha1.Network{} + err = c.client.Put(). + Namespace(c.ns). + Resource("networks"). + Name(network.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(network). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the network and deletes it. Returns an error if one occurs. +func (c *networks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("networks"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *networks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("networks"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched network. +func (c *networks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Network, err error) { + result = &v1alpha1.Network{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("networks"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied network. +func (c *networks) Apply(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) { + if network == nil { + return nil, fmt.Errorf("network provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(network) + if err != nil { + return nil, err + } + name := network.Name + if name == nil { + return nil, fmt.Errorf("network.Name must be provided to Apply") + } + result = &v1alpha1.Network{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("networks"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *networks) ApplyStatus(ctx context.Context, network *corev1alpha1.NetworkApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Network, err error) { + if network == nil { + return nil, fmt.Errorf("network provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(network) + if err != nil { + return nil, err + } + + name := network.Name + if name == nil { + return nil, fmt.Errorf("network.Name must be provided to Apply") + } + + result = &v1alpha1.Network{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("networks"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/networkid.go b/client-go/onmetalapinet/typed/core/v1alpha1/networkid.go new file mode 100644 index 00000000..56003b9d --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/networkid.go @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NetworkIDsGetter has a method to return a NetworkIDInterface. +// A group's client should implement this interface. +type NetworkIDsGetter interface { + NetworkIDs() NetworkIDInterface +} + +// NetworkIDInterface has methods to work with NetworkID resources. +type NetworkIDInterface interface { + Create(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.CreateOptions) (*v1alpha1.NetworkID, error) + Update(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.UpdateOptions) (*v1alpha1.NetworkID, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NetworkID, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NetworkIDList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkID, err error) + Apply(ctx context.Context, networkID *corev1alpha1.NetworkIDApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkID, err error) + NetworkIDExpansion +} + +// networkIDs implements NetworkIDInterface +type networkIDs struct { + client rest.Interface +} + +// newNetworkIDs returns a NetworkIDs +func newNetworkIDs(c *CoreV1alpha1Client) *networkIDs { + return &networkIDs{ + client: c.RESTClient(), + } +} + +// Get takes name of the networkID, and returns the corresponding networkID object, and an error if there is any. +func (c *networkIDs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkID, err error) { + result = &v1alpha1.NetworkID{} + err = c.client.Get(). + Resource("networkids"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NetworkIDs that match those selectors. +func (c *networkIDs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkIDList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NetworkIDList{} + err = c.client.Get(). + Resource("networkids"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested networkIDs. +func (c *networkIDs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("networkids"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a networkID and creates it. Returns the server's representation of the networkID, and an error, if there is any. +func (c *networkIDs) Create(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.CreateOptions) (result *v1alpha1.NetworkID, err error) { + result = &v1alpha1.NetworkID{} + err = c.client.Post(). + Resource("networkids"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(networkID). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a networkID and updates it. Returns the server's representation of the networkID, and an error, if there is any. +func (c *networkIDs) Update(ctx context.Context, networkID *v1alpha1.NetworkID, opts v1.UpdateOptions) (result *v1alpha1.NetworkID, err error) { + result = &v1alpha1.NetworkID{} + err = c.client.Put(). + Resource("networkids"). + Name(networkID.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(networkID). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the networkID and deletes it. Returns an error if one occurs. +func (c *networkIDs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("networkids"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *networkIDs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("networkids"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched networkID. +func (c *networkIDs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkID, err error) { + result = &v1alpha1.NetworkID{} + err = c.client.Patch(pt). + Resource("networkids"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied networkID. +func (c *networkIDs) Apply(ctx context.Context, networkID *corev1alpha1.NetworkIDApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkID, err error) { + if networkID == nil { + return nil, fmt.Errorf("networkID provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(networkID) + if err != nil { + return nil, err + } + name := networkID.Name + if name == nil { + return nil, fmt.Errorf("networkID.Name must be provided to Apply") + } + result = &v1alpha1.NetworkID{} + err = c.client.Patch(types.ApplyPatchType). + Resource("networkids"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/networkinterface.go b/client-go/onmetalapinet/typed/core/v1alpha1/networkinterface.go new file mode 100644 index 00000000..66069284 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/networkinterface.go @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NetworkInterfacesGetter has a method to return a NetworkInterfaceInterface. +// A group's client should implement this interface. +type NetworkInterfacesGetter interface { + NetworkInterfaces(namespace string) NetworkInterfaceInterface +} + +// NetworkInterfaceInterface has methods to work with NetworkInterface resources. +type NetworkInterfaceInterface interface { + Create(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.CreateOptions) (*v1alpha1.NetworkInterface, error) + Update(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (*v1alpha1.NetworkInterface, error) + UpdateStatus(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (*v1alpha1.NetworkInterface, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.NetworkInterface, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NetworkInterfaceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkInterface, err error) + Apply(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) + ApplyStatus(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) + NetworkInterfaceExpansion +} + +// networkInterfaces implements NetworkInterfaceInterface +type networkInterfaces struct { + client rest.Interface + ns string +} + +// newNetworkInterfaces returns a NetworkInterfaces +func newNetworkInterfaces(c *CoreV1alpha1Client, namespace string) *networkInterfaces { + return &networkInterfaces{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the networkInterface, and returns the corresponding networkInterface object, and an error if there is any. +func (c *networkInterfaces) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkInterface, err error) { + result = &v1alpha1.NetworkInterface{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NetworkInterfaces that match those selectors. +func (c *networkInterfaces) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkInterfaceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NetworkInterfaceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networkinterfaces"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested networkInterfaces. +func (c *networkInterfaces) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("networkinterfaces"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a networkInterface and creates it. Returns the server's representation of the networkInterface, and an error, if there is any. +func (c *networkInterfaces) Create(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.CreateOptions) (result *v1alpha1.NetworkInterface, err error) { + result = &v1alpha1.NetworkInterface{} + err = c.client.Post(). + Namespace(c.ns). + Resource("networkinterfaces"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(networkInterface). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a networkInterface and updates it. Returns the server's representation of the networkInterface, and an error, if there is any. +func (c *networkInterfaces) Update(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (result *v1alpha1.NetworkInterface, err error) { + result = &v1alpha1.NetworkInterface{} + err = c.client.Put(). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(networkInterface.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(networkInterface). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *networkInterfaces) UpdateStatus(ctx context.Context, networkInterface *v1alpha1.NetworkInterface, opts v1.UpdateOptions) (result *v1alpha1.NetworkInterface, err error) { + result = &v1alpha1.NetworkInterface{} + err = c.client.Put(). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(networkInterface.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(networkInterface). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the networkInterface and deletes it. Returns an error if one occurs. +func (c *networkInterfaces) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *networkInterfaces) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("networkinterfaces"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched networkInterface. +func (c *networkInterfaces) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkInterface, err error) { + result = &v1alpha1.NetworkInterface{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied networkInterface. +func (c *networkInterfaces) Apply(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) { + if networkInterface == nil { + return nil, fmt.Errorf("networkInterface provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(networkInterface) + if err != nil { + return nil, err + } + name := networkInterface.Name + if name == nil { + return nil, fmt.Errorf("networkInterface.Name must be provided to Apply") + } + result = &v1alpha1.NetworkInterface{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *networkInterfaces) ApplyStatus(ctx context.Context, networkInterface *corev1alpha1.NetworkInterfaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.NetworkInterface, err error) { + if networkInterface == nil { + return nil, fmt.Errorf("networkInterface provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(networkInterface) + if err != nil { + return nil, err + } + + name := networkInterface.Name + if name == nil { + return nil, fmt.Errorf("networkInterface.Name must be provided to Apply") + } + + result = &v1alpha1.NetworkInterface{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("networkinterfaces"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/onmetalapinet/typed/core/v1alpha1/node.go b/client-go/onmetalapinet/typed/core/v1alpha1/node.go new file mode 100644 index 00000000..c5a944b8 --- /dev/null +++ b/client-go/onmetalapinet/typed/core/v1alpha1/node.go @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2022 by the OnMetal 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 client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1alpha1 "github.com/onmetal/onmetal-api-net/client-go/applyconfigurations/core/v1alpha1" + scheme "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// NodesGetter has a method to return a NodeInterface. +// A group's client should implement this interface. +type NodesGetter interface { + Nodes() NodeInterface +} + +// NodeInterface has methods to work with Node resources. +type NodeInterface interface { + Create(ctx context.Context, node *v1alpha1.Node, opts v1.CreateOptions) (*v1alpha1.Node, error) + Update(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (*v1alpha1.Node, error) + UpdateStatus(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (*v1alpha1.Node, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Node, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Node, err error) + Apply(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) + ApplyStatus(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) + NodeExpansion +} + +// nodes implements NodeInterface +type nodes struct { + client rest.Interface +} + +// newNodes returns a Nodes +func newNodes(c *CoreV1alpha1Client) *nodes { + return &nodes{ + client: c.RESTClient(), + } +} + +// Get takes name of the node, and returns the corresponding node object, and an error if there is any. +func (c *nodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Node, err error) { + result = &v1alpha1.Node{} + err = c.client.Get(). + Resource("nodes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Nodes that match those selectors. +func (c *nodes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NodeList{} + err = c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nodes. +func (c *nodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a node and creates it. Returns the server's representation of the node, and an error, if there is any. +func (c *nodes) Create(ctx context.Context, node *v1alpha1.Node, opts v1.CreateOptions) (result *v1alpha1.Node, err error) { + result = &v1alpha1.Node{} + err = c.client.Post(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(node). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a node and updates it. Returns the server's representation of the node, and an error, if there is any. +func (c *nodes) Update(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (result *v1alpha1.Node, err error) { + result = &v1alpha1.Node{} + err = c.client.Put(). + Resource("nodes"). + Name(node.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(node). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *nodes) UpdateStatus(ctx context.Context, node *v1alpha1.Node, opts v1.UpdateOptions) (result *v1alpha1.Node, err error) { + result = &v1alpha1.Node{} + err = c.client.Put(). + Resource("nodes"). + Name(node.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(node). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the node and deletes it. Returns an error if one occurs. +func (c *nodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("nodes"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("nodes"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched node. +func (c *nodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Node, err error) { + result = &v1alpha1.Node{} + err = c.client.Patch(pt). + Resource("nodes"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied node. +func (c *nodes) Apply(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) { + if node == nil { + return nil, fmt.Errorf("node provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(node) + if err != nil { + return nil, err + } + name := node.Name + if name == nil { + return nil, fmt.Errorf("node.Name must be provided to Apply") + } + result = &v1alpha1.Node{} + err = c.client.Patch(types.ApplyPatchType). + Resource("nodes"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *nodes) ApplyStatus(ctx context.Context, node *corev1alpha1.NodeApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Node, err error) { + if node == nil { + return nil, fmt.Errorf("node provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(node) + if err != nil { + return nil, err + } + + name := node.Name + if name == nil { + return nil, fmt.Errorf("node.Name must be provided to Apply") + } + + result = &v1alpha1.Node{} + err = c.client.Patch(types.ApplyPatchType). + Resource("nodes"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/openapi/api_violations.report b/client-go/openapi/api_violations.report new file mode 100644 index 00000000..b53c6c06 --- /dev/null +++ b/client-go/openapi/api_violations.report @@ -0,0 +1,199 @@ +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceAntiAffinity,RequiredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceSpec,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceSpec,LoadBalancerPorts +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceSpec,TopologySpreadConstraints +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceStatus,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerRouting,Destinations +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerRouting,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerSpec,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerSpec,Ports +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerStatus,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NATGatewaySpec,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NATIP,Sections +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NATTable,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,IPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,NATs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,Prefixes +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,PublicIPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceStatus,NATIPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceStatus,Prefixes +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceStatus,PublicIPs +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NodeSelector,NodeSelectorTerms +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NodeSelectorRequirement,Values +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NodeSelectorTerm,MatchExpressions +API rule violation: list_type_missing,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NodeSelectorTerm,MatchFields +API rule violation: list_type_missing,k8s.io/api/core/v1,AvoidPods,PreferAvoidPods +API rule violation: list_type_missing,k8s.io/api/core/v1,Capabilities,Add +API rule violation: list_type_missing,k8s.io/api/core/v1,Capabilities,Drop +API rule violation: list_type_missing,k8s.io/api/core/v1,CephFSPersistentVolumeSource,Monitors +API rule violation: list_type_missing,k8s.io/api/core/v1,CephFSVolumeSource,Monitors +API rule violation: list_type_missing,k8s.io/api/core/v1,ComponentStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,ConfigMapProjection,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,ConfigMapVolumeSource,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,Args +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,Command +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,Env +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,EnvFrom +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,VolumeDevices +API rule violation: list_type_missing,k8s.io/api/core/v1,Container,VolumeMounts +API rule violation: list_type_missing,k8s.io/api/core/v1,ContainerImage,Names +API rule violation: list_type_missing,k8s.io/api/core/v1,DownwardAPIProjection,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,DownwardAPIVolumeSource,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,Addresses +API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,NotReadyAddresses +API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,Ports +API rule violation: list_type_missing,k8s.io/api/core/v1,Endpoints,Subsets +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Args +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Command +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Env +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,EnvFrom +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,VolumeDevices +API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,VolumeMounts +API rule violation: list_type_missing,k8s.io/api/core/v1,ExecAction,Command +API rule violation: list_type_missing,k8s.io/api/core/v1,FCVolumeSource,TargetWWNs +API rule violation: list_type_missing,k8s.io/api/core/v1,FCVolumeSource,WWIDs +API rule violation: list_type_missing,k8s.io/api/core/v1,HTTPGetAction,HTTPHeaders +API rule violation: list_type_missing,k8s.io/api/core/v1,HostAlias,Hostnames +API rule violation: list_type_missing,k8s.io/api/core/v1,ISCSIPersistentVolumeSource,Portals +API rule violation: list_type_missing,k8s.io/api/core/v1,ISCSIVolumeSource,Portals +API rule violation: list_type_missing,k8s.io/api/core/v1,LimitRangeSpec,Limits +API rule violation: list_type_missing,k8s.io/api/core/v1,LoadBalancerStatus,Ingress +API rule violation: list_type_missing,k8s.io/api/core/v1,NamespaceSpec,Finalizers +API rule violation: list_type_missing,k8s.io/api/core/v1,NamespaceStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeAffinity,PreferredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelector,NodeSelectorTerms +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorRequirement,Values +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorTerm,MatchExpressions +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorTerm,MatchFields +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSpec,PodCIDRs +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSpec,Taints +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Addresses +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Images +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,VolumesAttached +API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,VolumesInUse +API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimSpec,AccessModes +API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimStatus,AccessModes +API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeSpec,AccessModes +API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeSpec,MountOptions +API rule violation: list_type_missing,k8s.io/api/core/v1,PodAffinity,PreferredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,k8s.io/api/core/v1,PodAffinity,RequiredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,k8s.io/api/core/v1,PodAffinityTerm,Namespaces +API rule violation: list_type_missing,k8s.io/api/core/v1,PodAntiAffinity,PreferredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,k8s.io/api/core/v1,PodAntiAffinity,RequiredDuringSchedulingIgnoredDuringExecution +API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Nameservers +API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Options +API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Searches +API rule violation: list_type_missing,k8s.io/api/core/v1,PodExecOptions,Command +API rule violation: list_type_missing,k8s.io/api/core/v1,PodPortForwardOptions,Ports +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSecurityContext,SupplementalGroups +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSecurityContext,Sysctls +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Containers +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,EphemeralContainers +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,HostAliases +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,ImagePullSecrets +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,InitContainers +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,ReadinessGates +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Tolerations +API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Volumes +API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,ContainerStatuses +API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,EphemeralContainerStatuses +API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,InitContainerStatuses +API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,PodIPs +API rule violation: list_type_missing,k8s.io/api/core/v1,ProjectedVolumeSource,Sources +API rule violation: list_type_missing,k8s.io/api/core/v1,RBDPersistentVolumeSource,CephMonitors +API rule violation: list_type_missing,k8s.io/api/core/v1,RBDVolumeSource,CephMonitors +API rule violation: list_type_missing,k8s.io/api/core/v1,RangeAllocation,Data +API rule violation: list_type_missing,k8s.io/api/core/v1,ReplicationControllerStatus,Conditions +API rule violation: list_type_missing,k8s.io/api/core/v1,ResourceQuotaSpec,Scopes +API rule violation: list_type_missing,k8s.io/api/core/v1,ScopeSelector,MatchExpressions +API rule violation: list_type_missing,k8s.io/api/core/v1,ScopedResourceSelectorRequirement,Values +API rule violation: list_type_missing,k8s.io/api/core/v1,SecretProjection,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,SecretVolumeSource,Items +API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccount,ImagePullSecrets +API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccount,Secrets +API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceSpec,ExternalIPs +API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceSpec,LoadBalancerSourceRanges +API rule violation: list_type_missing,k8s.io/api/core/v1,TopologySelectorLabelRequirement,Values +API rule violation: list_type_missing,k8s.io/api/core/v1,TopologySelectorTerm,MatchLabelExpressions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroup,ServerAddressByClientCIDRs +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroup,Versions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroupList,Groups +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResource,Categories +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResource,ShortNames +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVersions,ServerAddressByClientCIDRs +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVersions,Versions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ApplyOptions,DryRun +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,CreateOptions,DryRun +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,DeleteOptions,DryRun +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,FieldsV1,Raw +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelector,MatchExpressions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelectorRequirement,Values +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,Finalizers +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ManagedFields +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,OwnerReferences +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,PatchOptions,DryRun +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,RootPaths,Paths +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,StatusDetails,Causes +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,ColumnDefinitions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,Rows +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Cells +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Conditions +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,UpdateOptions,DryRun +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,RawExtension,Raw +API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,Unknown,Raw +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,DaemonSetSpec,Selector +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceSpec,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,InstanceStatus,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerRouting,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerSpec,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerSpec,Selector +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,LoadBalancerStatus,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NATGatewaySpec,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NATTable,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,IPs +API rule violation: names_match,github.com/onmetal/onmetal-api-net/api/core/v1alpha1,NetworkInterfaceSpec,NATs +API rule violation: names_match,k8s.io/api/core/v1,AzureDiskVolumeSource,DataDiskURI +API rule violation: names_match,k8s.io/api/core/v1,ContainerStatus,LastTerminationState +API rule violation: names_match,k8s.io/api/core/v1,DaemonEndpoint,Port +API rule violation: names_match,k8s.io/api/core/v1,Event,ReportingController +API rule violation: names_match,k8s.io/api/core/v1,FCVolumeSource,WWIDs +API rule violation: names_match,k8s.io/api/core/v1,GlusterfsPersistentVolumeSource,EndpointsName +API rule violation: names_match,k8s.io/api/core/v1,GlusterfsVolumeSource,EndpointsName +API rule violation: names_match,k8s.io/api/core/v1,ISCSIPersistentVolumeSource,DiscoveryCHAPAuth +API rule violation: names_match,k8s.io/api/core/v1,ISCSIPersistentVolumeSource,SessionCHAPAuth +API rule violation: names_match,k8s.io/api/core/v1,ISCSIVolumeSource,DiscoveryCHAPAuth +API rule violation: names_match,k8s.io/api/core/v1,ISCSIVolumeSource,SessionCHAPAuth +API rule violation: names_match,k8s.io/api/core/v1,NodeResources,Capacity +API rule violation: names_match,k8s.io/api/core/v1,NodeSpec,DoNotUseExternalID +API rule violation: names_match,k8s.io/api/core/v1,PersistentVolumeSource,CephFS +API rule violation: names_match,k8s.io/api/core/v1,PersistentVolumeSource,StorageOS +API rule violation: names_match,k8s.io/api/core/v1,PodSpec,DeprecatedServiceAccount +API rule violation: names_match,k8s.io/api/core/v1,RBDPersistentVolumeSource,CephMonitors +API rule violation: names_match,k8s.io/api/core/v1,RBDPersistentVolumeSource,RBDImage +API rule violation: names_match,k8s.io/api/core/v1,RBDPersistentVolumeSource,RBDPool +API rule violation: names_match,k8s.io/api/core/v1,RBDPersistentVolumeSource,RadosUser +API rule violation: names_match,k8s.io/api/core/v1,RBDVolumeSource,CephMonitors +API rule violation: names_match,k8s.io/api/core/v1,RBDVolumeSource,RBDImage +API rule violation: names_match,k8s.io/api/core/v1,RBDVolumeSource,RBDPool +API rule violation: names_match,k8s.io/api/core/v1,RBDVolumeSource,RadosUser +API rule violation: names_match,k8s.io/api/core/v1,VolumeSource,CephFS +API rule violation: names_match,k8s.io/api/core/v1,VolumeSource,StorageOS +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,Format +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,d +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,i +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,s +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,int64Amount,scale +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,int64Amount,value +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Duration +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time +API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding +API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentType diff --git a/client-go/openapi/zz_generated.openapi.go b/client-go/openapi/zz_generated.openapi.go new file mode 100644 index 00000000..f89cb904 --- /dev/null +++ b/client-go/openapi/zz_generated.openapi.go @@ -0,0 +1,17823 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * Copyright (c) 2022 by the OnMetal 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 openapi-gen. DO NOT EDIT. + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package openapi + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + resource "k8s.io/apimachinery/pkg/api/resource" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + common "k8s.io/kube-openapi/pkg/common" + spec "k8s.io/kube-openapi/pkg/validation/spec" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Affinity": schema_onmetal_api_net_api_core_v1alpha1_Affinity(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSet": schema_onmetal_api_net_api_core_v1alpha1_DaemonSet(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetList": schema_onmetal_api_net_api_core_v1alpha1_DaemonSetList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetSpec": schema_onmetal_api_net_api_core_v1alpha1_DaemonSetSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetStatus": schema_onmetal_api_net_api_core_v1alpha1_DaemonSetStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IP": schema_onmetal_api_net_api_core_v1alpha1_IP(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddress": schema_onmetal_api_net_api_core_v1alpha1_IPAddress(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressClaimRef": schema_onmetal_api_net_api_core_v1alpha1_IPAddressClaimRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressList": schema_onmetal_api_net_api_core_v1alpha1_IPAddressList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressSpec": schema_onmetal_api_net_api_core_v1alpha1_IPAddressSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPClaimRef": schema_onmetal_api_net_api_core_v1alpha1_IPClaimRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPList": schema_onmetal_api_net_api_core_v1alpha1_IPList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPSpec": schema_onmetal_api_net_api_core_v1alpha1_IPSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPStatus": schema_onmetal_api_net_api_core_v1alpha1_IPStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Instance": schema_onmetal_api_net_api_core_v1alpha1_Instance(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAffinityTerm": schema_onmetal_api_net_api_core_v1alpha1_InstanceAffinityTerm(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAntiAffinity": schema_onmetal_api_net_api_core_v1alpha1_InstanceAntiAffinity(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceList": schema_onmetal_api_net_api_core_v1alpha1_InstanceList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceSpec": schema_onmetal_api_net_api_core_v1alpha1_InstanceSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceStatus": schema_onmetal_api_net_api_core_v1alpha1_InstanceStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceTemplate": schema_onmetal_api_net_api_core_v1alpha1_InstanceTemplate(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancer": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancer(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerDestination": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerDestination(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerIP": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerIP(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerList": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerPort": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerPort(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerRouting": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerRouting(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerRoutingList": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerRoutingList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerSpec": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerStatus": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerTargetRef": schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerTargetRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGateway": schema_onmetal_api_net_api_core_v1alpha1_NATGateway(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscaler": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscaler(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerList": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerSpec": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerStatus": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayIP": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayIP(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayList": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewaySpec": schema_onmetal_api_net_api_core_v1alpha1_NATGatewaySpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayStatus": schema_onmetal_api_net_api_core_v1alpha1_NATGatewayStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIP": schema_onmetal_api_net_api_core_v1alpha1_NATIP(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIPSection": schema_onmetal_api_net_api_core_v1alpha1_NATIPSection(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTable": schema_onmetal_api_net_api_core_v1alpha1_NATTable(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTableIPTargetRef": schema_onmetal_api_net_api_core_v1alpha1_NATTableIPTargetRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTableList": schema_onmetal_api_net_api_core_v1alpha1_NATTableList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Network": schema_onmetal_api_net_api_core_v1alpha1_Network(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkID": schema_onmetal_api_net_api_core_v1alpha1_NetworkID(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDClaimRef": schema_onmetal_api_net_api_core_v1alpha1_NetworkIDClaimRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDList": schema_onmetal_api_net_api_core_v1alpha1_NetworkIDList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDSpec": schema_onmetal_api_net_api_core_v1alpha1_NetworkIDSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterface": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterface(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceList": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNAT": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceNAT(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNATClaimRef": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceNATClaimRef(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfacePublicIP": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfacePublicIP(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceSpec": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceStatus": schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkList": schema_onmetal_api_net_api_core_v1alpha1_NetworkList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkSpec": schema_onmetal_api_net_api_core_v1alpha1_NetworkSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkStatus": schema_onmetal_api_net_api_core_v1alpha1_NetworkStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Node": schema_onmetal_api_net_api_core_v1alpha1_Node(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeAffinity": schema_onmetal_api_net_api_core_v1alpha1_NodeAffinity(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeList": schema_onmetal_api_net_api_core_v1alpha1_NodeList(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelector": schema_onmetal_api_net_api_core_v1alpha1_NodeSelector(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorRequirement": schema_onmetal_api_net_api_core_v1alpha1_NodeSelectorRequirement(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorTerm": schema_onmetal_api_net_api_core_v1alpha1_NodeSelectorTerm(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSpec": schema_onmetal_api_net_api_core_v1alpha1_NodeSpec(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeStatus": schema_onmetal_api_net_api_core_v1alpha1_NodeStatus(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.PCIAddress": schema_onmetal_api_net_api_core_v1alpha1_PCIAddress(ref), + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.TopologySpreadConstraint": schema_onmetal_api_net_api_core_v1alpha1_TopologySpreadConstraint(ref), + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP": schema_onmetal_api_net_apimachinery_api_net_IP(ref), + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IPPrefix": schema_onmetal_api_net_apimachinery_api_net_IPPrefix(ref), + "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource": schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref), + "k8s.io/api/core/v1.Affinity": schema_k8sio_api_core_v1_Affinity(ref), + "k8s.io/api/core/v1.AttachedVolume": schema_k8sio_api_core_v1_AttachedVolume(ref), + "k8s.io/api/core/v1.AvoidPods": schema_k8sio_api_core_v1_AvoidPods(ref), + "k8s.io/api/core/v1.AzureDiskVolumeSource": schema_k8sio_api_core_v1_AzureDiskVolumeSource(ref), + "k8s.io/api/core/v1.AzureFilePersistentVolumeSource": schema_k8sio_api_core_v1_AzureFilePersistentVolumeSource(ref), + "k8s.io/api/core/v1.AzureFileVolumeSource": schema_k8sio_api_core_v1_AzureFileVolumeSource(ref), + "k8s.io/api/core/v1.Binding": schema_k8sio_api_core_v1_Binding(ref), + "k8s.io/api/core/v1.CSIPersistentVolumeSource": schema_k8sio_api_core_v1_CSIPersistentVolumeSource(ref), + "k8s.io/api/core/v1.CSIVolumeSource": schema_k8sio_api_core_v1_CSIVolumeSource(ref), + "k8s.io/api/core/v1.Capabilities": schema_k8sio_api_core_v1_Capabilities(ref), + "k8s.io/api/core/v1.CephFSPersistentVolumeSource": schema_k8sio_api_core_v1_CephFSPersistentVolumeSource(ref), + "k8s.io/api/core/v1.CephFSVolumeSource": schema_k8sio_api_core_v1_CephFSVolumeSource(ref), + "k8s.io/api/core/v1.CinderPersistentVolumeSource": schema_k8sio_api_core_v1_CinderPersistentVolumeSource(ref), + "k8s.io/api/core/v1.CinderVolumeSource": schema_k8sio_api_core_v1_CinderVolumeSource(ref), + "k8s.io/api/core/v1.ClaimSource": schema_k8sio_api_core_v1_ClaimSource(ref), + "k8s.io/api/core/v1.ClientIPConfig": schema_k8sio_api_core_v1_ClientIPConfig(ref), + "k8s.io/api/core/v1.ComponentCondition": schema_k8sio_api_core_v1_ComponentCondition(ref), + "k8s.io/api/core/v1.ComponentStatus": schema_k8sio_api_core_v1_ComponentStatus(ref), + "k8s.io/api/core/v1.ComponentStatusList": schema_k8sio_api_core_v1_ComponentStatusList(ref), + "k8s.io/api/core/v1.ConfigMap": schema_k8sio_api_core_v1_ConfigMap(ref), + "k8s.io/api/core/v1.ConfigMapEnvSource": schema_k8sio_api_core_v1_ConfigMapEnvSource(ref), + "k8s.io/api/core/v1.ConfigMapKeySelector": schema_k8sio_api_core_v1_ConfigMapKeySelector(ref), + "k8s.io/api/core/v1.ConfigMapList": schema_k8sio_api_core_v1_ConfigMapList(ref), + "k8s.io/api/core/v1.ConfigMapNodeConfigSource": schema_k8sio_api_core_v1_ConfigMapNodeConfigSource(ref), + "k8s.io/api/core/v1.ConfigMapProjection": schema_k8sio_api_core_v1_ConfigMapProjection(ref), + "k8s.io/api/core/v1.ConfigMapVolumeSource": schema_k8sio_api_core_v1_ConfigMapVolumeSource(ref), + "k8s.io/api/core/v1.Container": schema_k8sio_api_core_v1_Container(ref), + "k8s.io/api/core/v1.ContainerImage": schema_k8sio_api_core_v1_ContainerImage(ref), + "k8s.io/api/core/v1.ContainerPort": schema_k8sio_api_core_v1_ContainerPort(ref), + "k8s.io/api/core/v1.ContainerResizePolicy": schema_k8sio_api_core_v1_ContainerResizePolicy(ref), + "k8s.io/api/core/v1.ContainerState": schema_k8sio_api_core_v1_ContainerState(ref), + "k8s.io/api/core/v1.ContainerStateRunning": schema_k8sio_api_core_v1_ContainerStateRunning(ref), + "k8s.io/api/core/v1.ContainerStateTerminated": schema_k8sio_api_core_v1_ContainerStateTerminated(ref), + "k8s.io/api/core/v1.ContainerStateWaiting": schema_k8sio_api_core_v1_ContainerStateWaiting(ref), + "k8s.io/api/core/v1.ContainerStatus": schema_k8sio_api_core_v1_ContainerStatus(ref), + "k8s.io/api/core/v1.DaemonEndpoint": schema_k8sio_api_core_v1_DaemonEndpoint(ref), + "k8s.io/api/core/v1.DownwardAPIProjection": schema_k8sio_api_core_v1_DownwardAPIProjection(ref), + "k8s.io/api/core/v1.DownwardAPIVolumeFile": schema_k8sio_api_core_v1_DownwardAPIVolumeFile(ref), + "k8s.io/api/core/v1.DownwardAPIVolumeSource": schema_k8sio_api_core_v1_DownwardAPIVolumeSource(ref), + "k8s.io/api/core/v1.EmptyDirVolumeSource": schema_k8sio_api_core_v1_EmptyDirVolumeSource(ref), + "k8s.io/api/core/v1.EndpointAddress": schema_k8sio_api_core_v1_EndpointAddress(ref), + "k8s.io/api/core/v1.EndpointPort": schema_k8sio_api_core_v1_EndpointPort(ref), + "k8s.io/api/core/v1.EndpointSubset": schema_k8sio_api_core_v1_EndpointSubset(ref), + "k8s.io/api/core/v1.Endpoints": schema_k8sio_api_core_v1_Endpoints(ref), + "k8s.io/api/core/v1.EndpointsList": schema_k8sio_api_core_v1_EndpointsList(ref), + "k8s.io/api/core/v1.EnvFromSource": schema_k8sio_api_core_v1_EnvFromSource(ref), + "k8s.io/api/core/v1.EnvVar": schema_k8sio_api_core_v1_EnvVar(ref), + "k8s.io/api/core/v1.EnvVarSource": schema_k8sio_api_core_v1_EnvVarSource(ref), + "k8s.io/api/core/v1.EphemeralContainer": schema_k8sio_api_core_v1_EphemeralContainer(ref), + "k8s.io/api/core/v1.EphemeralContainerCommon": schema_k8sio_api_core_v1_EphemeralContainerCommon(ref), + "k8s.io/api/core/v1.EphemeralVolumeSource": schema_k8sio_api_core_v1_EphemeralVolumeSource(ref), + "k8s.io/api/core/v1.Event": schema_k8sio_api_core_v1_Event(ref), + "k8s.io/api/core/v1.EventList": schema_k8sio_api_core_v1_EventList(ref), + "k8s.io/api/core/v1.EventSeries": schema_k8sio_api_core_v1_EventSeries(ref), + "k8s.io/api/core/v1.EventSource": schema_k8sio_api_core_v1_EventSource(ref), + "k8s.io/api/core/v1.ExecAction": schema_k8sio_api_core_v1_ExecAction(ref), + "k8s.io/api/core/v1.FCVolumeSource": schema_k8sio_api_core_v1_FCVolumeSource(ref), + "k8s.io/api/core/v1.FlexPersistentVolumeSource": schema_k8sio_api_core_v1_FlexPersistentVolumeSource(ref), + "k8s.io/api/core/v1.FlexVolumeSource": schema_k8sio_api_core_v1_FlexVolumeSource(ref), + "k8s.io/api/core/v1.FlockerVolumeSource": schema_k8sio_api_core_v1_FlockerVolumeSource(ref), + "k8s.io/api/core/v1.GCEPersistentDiskVolumeSource": schema_k8sio_api_core_v1_GCEPersistentDiskVolumeSource(ref), + "k8s.io/api/core/v1.GRPCAction": schema_k8sio_api_core_v1_GRPCAction(ref), + "k8s.io/api/core/v1.GitRepoVolumeSource": schema_k8sio_api_core_v1_GitRepoVolumeSource(ref), + "k8s.io/api/core/v1.GlusterfsPersistentVolumeSource": schema_k8sio_api_core_v1_GlusterfsPersistentVolumeSource(ref), + "k8s.io/api/core/v1.GlusterfsVolumeSource": schema_k8sio_api_core_v1_GlusterfsVolumeSource(ref), + "k8s.io/api/core/v1.HTTPGetAction": schema_k8sio_api_core_v1_HTTPGetAction(ref), + "k8s.io/api/core/v1.HTTPHeader": schema_k8sio_api_core_v1_HTTPHeader(ref), + "k8s.io/api/core/v1.HostAlias": schema_k8sio_api_core_v1_HostAlias(ref), + "k8s.io/api/core/v1.HostPathVolumeSource": schema_k8sio_api_core_v1_HostPathVolumeSource(ref), + "k8s.io/api/core/v1.ISCSIPersistentVolumeSource": schema_k8sio_api_core_v1_ISCSIPersistentVolumeSource(ref), + "k8s.io/api/core/v1.ISCSIVolumeSource": schema_k8sio_api_core_v1_ISCSIVolumeSource(ref), + "k8s.io/api/core/v1.KeyToPath": schema_k8sio_api_core_v1_KeyToPath(ref), + "k8s.io/api/core/v1.Lifecycle": schema_k8sio_api_core_v1_Lifecycle(ref), + "k8s.io/api/core/v1.LifecycleHandler": schema_k8sio_api_core_v1_LifecycleHandler(ref), + "k8s.io/api/core/v1.LimitRange": schema_k8sio_api_core_v1_LimitRange(ref), + "k8s.io/api/core/v1.LimitRangeItem": schema_k8sio_api_core_v1_LimitRangeItem(ref), + "k8s.io/api/core/v1.LimitRangeList": schema_k8sio_api_core_v1_LimitRangeList(ref), + "k8s.io/api/core/v1.LimitRangeSpec": schema_k8sio_api_core_v1_LimitRangeSpec(ref), + "k8s.io/api/core/v1.List": schema_k8sio_api_core_v1_List(ref), + "k8s.io/api/core/v1.LoadBalancerIngress": schema_k8sio_api_core_v1_LoadBalancerIngress(ref), + "k8s.io/api/core/v1.LoadBalancerStatus": schema_k8sio_api_core_v1_LoadBalancerStatus(ref), + "k8s.io/api/core/v1.LocalObjectReference": schema_k8sio_api_core_v1_LocalObjectReference(ref), + "k8s.io/api/core/v1.LocalVolumeSource": schema_k8sio_api_core_v1_LocalVolumeSource(ref), + "k8s.io/api/core/v1.NFSVolumeSource": schema_k8sio_api_core_v1_NFSVolumeSource(ref), + "k8s.io/api/core/v1.Namespace": schema_k8sio_api_core_v1_Namespace(ref), + "k8s.io/api/core/v1.NamespaceCondition": schema_k8sio_api_core_v1_NamespaceCondition(ref), + "k8s.io/api/core/v1.NamespaceList": schema_k8sio_api_core_v1_NamespaceList(ref), + "k8s.io/api/core/v1.NamespaceSpec": schema_k8sio_api_core_v1_NamespaceSpec(ref), + "k8s.io/api/core/v1.NamespaceStatus": schema_k8sio_api_core_v1_NamespaceStatus(ref), + "k8s.io/api/core/v1.Node": schema_k8sio_api_core_v1_Node(ref), + "k8s.io/api/core/v1.NodeAddress": schema_k8sio_api_core_v1_NodeAddress(ref), + "k8s.io/api/core/v1.NodeAffinity": schema_k8sio_api_core_v1_NodeAffinity(ref), + "k8s.io/api/core/v1.NodeCondition": schema_k8sio_api_core_v1_NodeCondition(ref), + "k8s.io/api/core/v1.NodeConfigSource": schema_k8sio_api_core_v1_NodeConfigSource(ref), + "k8s.io/api/core/v1.NodeConfigStatus": schema_k8sio_api_core_v1_NodeConfigStatus(ref), + "k8s.io/api/core/v1.NodeDaemonEndpoints": schema_k8sio_api_core_v1_NodeDaemonEndpoints(ref), + "k8s.io/api/core/v1.NodeList": schema_k8sio_api_core_v1_NodeList(ref), + "k8s.io/api/core/v1.NodeProxyOptions": schema_k8sio_api_core_v1_NodeProxyOptions(ref), + "k8s.io/api/core/v1.NodeResources": schema_k8sio_api_core_v1_NodeResources(ref), + "k8s.io/api/core/v1.NodeSelector": schema_k8sio_api_core_v1_NodeSelector(ref), + "k8s.io/api/core/v1.NodeSelectorRequirement": schema_k8sio_api_core_v1_NodeSelectorRequirement(ref), + "k8s.io/api/core/v1.NodeSelectorTerm": schema_k8sio_api_core_v1_NodeSelectorTerm(ref), + "k8s.io/api/core/v1.NodeSpec": schema_k8sio_api_core_v1_NodeSpec(ref), + "k8s.io/api/core/v1.NodeStatus": schema_k8sio_api_core_v1_NodeStatus(ref), + "k8s.io/api/core/v1.NodeSystemInfo": schema_k8sio_api_core_v1_NodeSystemInfo(ref), + "k8s.io/api/core/v1.ObjectFieldSelector": schema_k8sio_api_core_v1_ObjectFieldSelector(ref), + "k8s.io/api/core/v1.ObjectReference": schema_k8sio_api_core_v1_ObjectReference(ref), + "k8s.io/api/core/v1.PersistentVolume": schema_k8sio_api_core_v1_PersistentVolume(ref), + "k8s.io/api/core/v1.PersistentVolumeClaim": schema_k8sio_api_core_v1_PersistentVolumeClaim(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimCondition": schema_k8sio_api_core_v1_PersistentVolumeClaimCondition(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimList": schema_k8sio_api_core_v1_PersistentVolumeClaimList(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimSpec": schema_k8sio_api_core_v1_PersistentVolumeClaimSpec(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimStatus": schema_k8sio_api_core_v1_PersistentVolumeClaimStatus(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimTemplate": schema_k8sio_api_core_v1_PersistentVolumeClaimTemplate(ref), + "k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource": schema_k8sio_api_core_v1_PersistentVolumeClaimVolumeSource(ref), + "k8s.io/api/core/v1.PersistentVolumeList": schema_k8sio_api_core_v1_PersistentVolumeList(ref), + "k8s.io/api/core/v1.PersistentVolumeSource": schema_k8sio_api_core_v1_PersistentVolumeSource(ref), + "k8s.io/api/core/v1.PersistentVolumeSpec": schema_k8sio_api_core_v1_PersistentVolumeSpec(ref), + "k8s.io/api/core/v1.PersistentVolumeStatus": schema_k8sio_api_core_v1_PersistentVolumeStatus(ref), + "k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource": schema_k8sio_api_core_v1_PhotonPersistentDiskVolumeSource(ref), + "k8s.io/api/core/v1.Pod": schema_k8sio_api_core_v1_Pod(ref), + "k8s.io/api/core/v1.PodAffinity": schema_k8sio_api_core_v1_PodAffinity(ref), + "k8s.io/api/core/v1.PodAffinityTerm": schema_k8sio_api_core_v1_PodAffinityTerm(ref), + "k8s.io/api/core/v1.PodAntiAffinity": schema_k8sio_api_core_v1_PodAntiAffinity(ref), + "k8s.io/api/core/v1.PodAttachOptions": schema_k8sio_api_core_v1_PodAttachOptions(ref), + "k8s.io/api/core/v1.PodCondition": schema_k8sio_api_core_v1_PodCondition(ref), + "k8s.io/api/core/v1.PodDNSConfig": schema_k8sio_api_core_v1_PodDNSConfig(ref), + "k8s.io/api/core/v1.PodDNSConfigOption": schema_k8sio_api_core_v1_PodDNSConfigOption(ref), + "k8s.io/api/core/v1.PodExecOptions": schema_k8sio_api_core_v1_PodExecOptions(ref), + "k8s.io/api/core/v1.PodIP": schema_k8sio_api_core_v1_PodIP(ref), + "k8s.io/api/core/v1.PodList": schema_k8sio_api_core_v1_PodList(ref), + "k8s.io/api/core/v1.PodLogOptions": schema_k8sio_api_core_v1_PodLogOptions(ref), + "k8s.io/api/core/v1.PodOS": schema_k8sio_api_core_v1_PodOS(ref), + "k8s.io/api/core/v1.PodPortForwardOptions": schema_k8sio_api_core_v1_PodPortForwardOptions(ref), + "k8s.io/api/core/v1.PodProxyOptions": schema_k8sio_api_core_v1_PodProxyOptions(ref), + "k8s.io/api/core/v1.PodReadinessGate": schema_k8sio_api_core_v1_PodReadinessGate(ref), + "k8s.io/api/core/v1.PodResourceClaim": schema_k8sio_api_core_v1_PodResourceClaim(ref), + "k8s.io/api/core/v1.PodSchedulingGate": schema_k8sio_api_core_v1_PodSchedulingGate(ref), + "k8s.io/api/core/v1.PodSecurityContext": schema_k8sio_api_core_v1_PodSecurityContext(ref), + "k8s.io/api/core/v1.PodSignature": schema_k8sio_api_core_v1_PodSignature(ref), + "k8s.io/api/core/v1.PodSpec": schema_k8sio_api_core_v1_PodSpec(ref), + "k8s.io/api/core/v1.PodStatus": schema_k8sio_api_core_v1_PodStatus(ref), + "k8s.io/api/core/v1.PodStatusResult": schema_k8sio_api_core_v1_PodStatusResult(ref), + "k8s.io/api/core/v1.PodTemplate": schema_k8sio_api_core_v1_PodTemplate(ref), + "k8s.io/api/core/v1.PodTemplateList": schema_k8sio_api_core_v1_PodTemplateList(ref), + "k8s.io/api/core/v1.PodTemplateSpec": schema_k8sio_api_core_v1_PodTemplateSpec(ref), + "k8s.io/api/core/v1.PortStatus": schema_k8sio_api_core_v1_PortStatus(ref), + "k8s.io/api/core/v1.PortworxVolumeSource": schema_k8sio_api_core_v1_PortworxVolumeSource(ref), + "k8s.io/api/core/v1.PreferAvoidPodsEntry": schema_k8sio_api_core_v1_PreferAvoidPodsEntry(ref), + "k8s.io/api/core/v1.PreferredSchedulingTerm": schema_k8sio_api_core_v1_PreferredSchedulingTerm(ref), + "k8s.io/api/core/v1.Probe": schema_k8sio_api_core_v1_Probe(ref), + "k8s.io/api/core/v1.ProbeHandler": schema_k8sio_api_core_v1_ProbeHandler(ref), + "k8s.io/api/core/v1.ProjectedVolumeSource": schema_k8sio_api_core_v1_ProjectedVolumeSource(ref), + "k8s.io/api/core/v1.QuobyteVolumeSource": schema_k8sio_api_core_v1_QuobyteVolumeSource(ref), + "k8s.io/api/core/v1.RBDPersistentVolumeSource": schema_k8sio_api_core_v1_RBDPersistentVolumeSource(ref), + "k8s.io/api/core/v1.RBDVolumeSource": schema_k8sio_api_core_v1_RBDVolumeSource(ref), + "k8s.io/api/core/v1.RangeAllocation": schema_k8sio_api_core_v1_RangeAllocation(ref), + "k8s.io/api/core/v1.ReplicationController": schema_k8sio_api_core_v1_ReplicationController(ref), + "k8s.io/api/core/v1.ReplicationControllerCondition": schema_k8sio_api_core_v1_ReplicationControllerCondition(ref), + "k8s.io/api/core/v1.ReplicationControllerList": schema_k8sio_api_core_v1_ReplicationControllerList(ref), + "k8s.io/api/core/v1.ReplicationControllerSpec": schema_k8sio_api_core_v1_ReplicationControllerSpec(ref), + "k8s.io/api/core/v1.ReplicationControllerStatus": schema_k8sio_api_core_v1_ReplicationControllerStatus(ref), + "k8s.io/api/core/v1.ResourceClaim": schema_k8sio_api_core_v1_ResourceClaim(ref), + "k8s.io/api/core/v1.ResourceFieldSelector": schema_k8sio_api_core_v1_ResourceFieldSelector(ref), + "k8s.io/api/core/v1.ResourceQuota": schema_k8sio_api_core_v1_ResourceQuota(ref), + "k8s.io/api/core/v1.ResourceQuotaList": schema_k8sio_api_core_v1_ResourceQuotaList(ref), + "k8s.io/api/core/v1.ResourceQuotaSpec": schema_k8sio_api_core_v1_ResourceQuotaSpec(ref), + "k8s.io/api/core/v1.ResourceQuotaStatus": schema_k8sio_api_core_v1_ResourceQuotaStatus(ref), + "k8s.io/api/core/v1.ResourceRequirements": schema_k8sio_api_core_v1_ResourceRequirements(ref), + "k8s.io/api/core/v1.SELinuxOptions": schema_k8sio_api_core_v1_SELinuxOptions(ref), + "k8s.io/api/core/v1.ScaleIOPersistentVolumeSource": schema_k8sio_api_core_v1_ScaleIOPersistentVolumeSource(ref), + "k8s.io/api/core/v1.ScaleIOVolumeSource": schema_k8sio_api_core_v1_ScaleIOVolumeSource(ref), + "k8s.io/api/core/v1.ScopeSelector": schema_k8sio_api_core_v1_ScopeSelector(ref), + "k8s.io/api/core/v1.ScopedResourceSelectorRequirement": schema_k8sio_api_core_v1_ScopedResourceSelectorRequirement(ref), + "k8s.io/api/core/v1.SeccompProfile": schema_k8sio_api_core_v1_SeccompProfile(ref), + "k8s.io/api/core/v1.Secret": schema_k8sio_api_core_v1_Secret(ref), + "k8s.io/api/core/v1.SecretEnvSource": schema_k8sio_api_core_v1_SecretEnvSource(ref), + "k8s.io/api/core/v1.SecretKeySelector": schema_k8sio_api_core_v1_SecretKeySelector(ref), + "k8s.io/api/core/v1.SecretList": schema_k8sio_api_core_v1_SecretList(ref), + "k8s.io/api/core/v1.SecretProjection": schema_k8sio_api_core_v1_SecretProjection(ref), + "k8s.io/api/core/v1.SecretReference": schema_k8sio_api_core_v1_SecretReference(ref), + "k8s.io/api/core/v1.SecretVolumeSource": schema_k8sio_api_core_v1_SecretVolumeSource(ref), + "k8s.io/api/core/v1.SecurityContext": schema_k8sio_api_core_v1_SecurityContext(ref), + "k8s.io/api/core/v1.SerializedReference": schema_k8sio_api_core_v1_SerializedReference(ref), + "k8s.io/api/core/v1.Service": schema_k8sio_api_core_v1_Service(ref), + "k8s.io/api/core/v1.ServiceAccount": schema_k8sio_api_core_v1_ServiceAccount(ref), + "k8s.io/api/core/v1.ServiceAccountList": schema_k8sio_api_core_v1_ServiceAccountList(ref), + "k8s.io/api/core/v1.ServiceAccountTokenProjection": schema_k8sio_api_core_v1_ServiceAccountTokenProjection(ref), + "k8s.io/api/core/v1.ServiceList": schema_k8sio_api_core_v1_ServiceList(ref), + "k8s.io/api/core/v1.ServicePort": schema_k8sio_api_core_v1_ServicePort(ref), + "k8s.io/api/core/v1.ServiceProxyOptions": schema_k8sio_api_core_v1_ServiceProxyOptions(ref), + "k8s.io/api/core/v1.ServiceSpec": schema_k8sio_api_core_v1_ServiceSpec(ref), + "k8s.io/api/core/v1.ServiceStatus": schema_k8sio_api_core_v1_ServiceStatus(ref), + "k8s.io/api/core/v1.SessionAffinityConfig": schema_k8sio_api_core_v1_SessionAffinityConfig(ref), + "k8s.io/api/core/v1.StorageOSPersistentVolumeSource": schema_k8sio_api_core_v1_StorageOSPersistentVolumeSource(ref), + "k8s.io/api/core/v1.StorageOSVolumeSource": schema_k8sio_api_core_v1_StorageOSVolumeSource(ref), + "k8s.io/api/core/v1.Sysctl": schema_k8sio_api_core_v1_Sysctl(ref), + "k8s.io/api/core/v1.TCPSocketAction": schema_k8sio_api_core_v1_TCPSocketAction(ref), + "k8s.io/api/core/v1.Taint": schema_k8sio_api_core_v1_Taint(ref), + "k8s.io/api/core/v1.Toleration": schema_k8sio_api_core_v1_Toleration(ref), + "k8s.io/api/core/v1.TopologySelectorLabelRequirement": schema_k8sio_api_core_v1_TopologySelectorLabelRequirement(ref), + "k8s.io/api/core/v1.TopologySelectorTerm": schema_k8sio_api_core_v1_TopologySelectorTerm(ref), + "k8s.io/api/core/v1.TopologySpreadConstraint": schema_k8sio_api_core_v1_TopologySpreadConstraint(ref), + "k8s.io/api/core/v1.TypedLocalObjectReference": schema_k8sio_api_core_v1_TypedLocalObjectReference(ref), + "k8s.io/api/core/v1.TypedObjectReference": schema_k8sio_api_core_v1_TypedObjectReference(ref), + "k8s.io/api/core/v1.Volume": schema_k8sio_api_core_v1_Volume(ref), + "k8s.io/api/core/v1.VolumeDevice": schema_k8sio_api_core_v1_VolumeDevice(ref), + "k8s.io/api/core/v1.VolumeMount": schema_k8sio_api_core_v1_VolumeMount(ref), + "k8s.io/api/core/v1.VolumeNodeAffinity": schema_k8sio_api_core_v1_VolumeNodeAffinity(ref), + "k8s.io/api/core/v1.VolumeProjection": schema_k8sio_api_core_v1_VolumeProjection(ref), + "k8s.io/api/core/v1.VolumeSource": schema_k8sio_api_core_v1_VolumeSource(ref), + "k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource": schema_k8sio_api_core_v1_VsphereVirtualDiskVolumeSource(ref), + "k8s.io/api/core/v1.WeightedPodAffinityTerm": schema_k8sio_api_core_v1_WeightedPodAffinityTerm(ref), + "k8s.io/api/core/v1.WindowsSecurityContextOptions": schema_k8sio_api_core_v1_WindowsSecurityContextOptions(ref), + "k8s.io/apimachinery/pkg/api/resource.Quantity": schema_apimachinery_pkg_api_resource_Quantity(ref), + "k8s.io/apimachinery/pkg/api/resource.int64Amount": schema_apimachinery_pkg_api_resource_int64Amount(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup": schema_pkg_apis_meta_v1_APIGroup(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroupList": schema_pkg_apis_meta_v1_APIGroupList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIResource": schema_pkg_apis_meta_v1_APIResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIResourceList": schema_pkg_apis_meta_v1_APIResourceList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIVersions": schema_pkg_apis_meta_v1_APIVersions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ApplyOptions": schema_pkg_apis_meta_v1_ApplyOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition": schema_pkg_apis_meta_v1_Condition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.CreateOptions": schema_pkg_apis_meta_v1_CreateOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.DeleteOptions": schema_pkg_apis_meta_v1_DeleteOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration": schema_pkg_apis_meta_v1_Duration(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1": schema_pkg_apis_meta_v1_FieldsV1(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GetOptions": schema_pkg_apis_meta_v1_GetOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupKind": schema_pkg_apis_meta_v1_GroupKind(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupResource": schema_pkg_apis_meta_v1_GroupResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersion": schema_pkg_apis_meta_v1_GroupVersion(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery": schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionKind": schema_pkg_apis_meta_v1_GroupVersionKind(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionResource": schema_pkg_apis_meta_v1_GroupVersionResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.InternalEvent": schema_pkg_apis_meta_v1_InternalEvent(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector": schema_pkg_apis_meta_v1_LabelSelector(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement": schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.List": schema_pkg_apis_meta_v1_List(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta": schema_pkg_apis_meta_v1_ListMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ListOptions": schema_pkg_apis_meta_v1_ListOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ManagedFieldsEntry": schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime": schema_pkg_apis_meta_v1_MicroTime(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta": schema_pkg_apis_meta_v1_ObjectMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference": schema_pkg_apis_meta_v1_OwnerReference(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadata": schema_pkg_apis_meta_v1_PartialObjectMetadata(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadataList": schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Patch": schema_pkg_apis_meta_v1_Patch(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PatchOptions": schema_pkg_apis_meta_v1_PatchOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Preconditions": schema_pkg_apis_meta_v1_Preconditions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.RootPaths": schema_pkg_apis_meta_v1_RootPaths(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR": schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Status": schema_pkg_apis_meta_v1_Status(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.StatusCause": schema_pkg_apis_meta_v1_StatusCause(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails": schema_pkg_apis_meta_v1_StatusDetails(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Table": schema_pkg_apis_meta_v1_Table(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableColumnDefinition": schema_pkg_apis_meta_v1_TableColumnDefinition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableOptions": schema_pkg_apis_meta_v1_TableOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableRow": schema_pkg_apis_meta_v1_TableRow(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableRowCondition": schema_pkg_apis_meta_v1_TableRowCondition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Time": schema_pkg_apis_meta_v1_Time(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Timestamp": schema_pkg_apis_meta_v1_Timestamp(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta": schema_pkg_apis_meta_v1_TypeMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.UpdateOptions": schema_pkg_apis_meta_v1_UpdateOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.WatchEvent": schema_pkg_apis_meta_v1_WatchEvent(ref), + "k8s.io/apimachinery/pkg/runtime.RawExtension": schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref), + "k8s.io/apimachinery/pkg/runtime.TypeMeta": schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref), + "k8s.io/apimachinery/pkg/runtime.Unknown": schema_k8sio_apimachinery_pkg_runtime_Unknown(ref), + "k8s.io/apimachinery/pkg/version.Info": schema_k8sio_apimachinery_pkg_version_Info(ref), + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_Affinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeAffinity": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeAffinity"), + }, + }, + "instanceAntiAffinity": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAntiAffinity"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAntiAffinity", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeAffinity"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_DaemonSet(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DaemonSet is the schema for the daemonsets API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSetStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_DaemonSetList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DaemonSetList contains a list of DaemonSet.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSet"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.DaemonSet", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_DaemonSetSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "Selector selects all Instance that are managed by this daemon set.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "template": { + SchemaProps: spec.SchemaProps{ + Description: "Template is the instance template.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceTemplate"), + }, + }, + }, + Required: []string{"template"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceTemplate", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_DaemonSetStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "collisionCount": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IP is the schema for the ips API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPAddress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IPAddress is the schema for the ipaddresses API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPAddressClaimRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPAddressList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IPAddressList contains a list of IPAddress.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddress"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddress", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPAddressSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + "claimRef": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressClaimRef"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPAddressClaimRef", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPClaimRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IPList contains a list of IP.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IP"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IP", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ipFamily": { + SchemaProps: spec.SchemaProps{ + Description: "Possible enum values:\n - `\"IPv4\"` indicates that this IP is IPv4 protocol\n - `\"IPv6\"` indicates that this IP is IPv6 protocol", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"IPv4", "IPv6"}, + }, + }, + "ip": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + "claimRef": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPClaimRef"), + }, + }, + }, + Required: []string{"type"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.IPClaimRef", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_IPStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_Instance(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Instance is the schema for the instances API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceAffinityTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceAffinityTerm defines a set of instances (namely those matching the labelSelector that this instance should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key matches that of any node on which a instance of the set of instances is running.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "LabelSelector over a set of resources, in this case instances.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "topologyKey": { + SchemaProps: spec.SchemaProps{ + Description: "TopologyKey indicates that this instance should be co-located (affinity) or not co-located (anti-affinity) with the instances matching the labelSelector, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected instances is running. Empty topologyKey is not allowed.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"topologyKey"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceAntiAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "requiredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "RequiredDuringSchedulingIgnoredDuringExecution specifies anti-affinity requirements at scheduling time, that, if not met, will cause the instance not be scheduled onto the node. When there are multiple elements, the lists of nodes corresponding to each instanceAffinityTerm are intersected, i.e. all terms must be satisfied.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAffinityTerm"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceAffinityTerm"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceList contains a list of Instance.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Instance"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Instance", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type specifies the InstanceType to deploy.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "loadBalancerType": { + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerType is the load balancer type this instance is for.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "networkRef": { + SchemaProps: spec.SchemaProps{ + Description: "NetworkRef references the network the instance is on.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "ips": { + SchemaProps: spec.SchemaProps{ + Description: "IPs are the IPs of the instance.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + "loadBalancerPorts": { + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerPorts are the load balancer ports of this instance.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerPort"), + }, + }, + }, + }, + }, + "affinity": { + SchemaProps: spec.SchemaProps{ + Description: "Affinity are affinity constraints.", + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Affinity"), + }, + }, + "topologySpreadConstraints": { + SchemaProps: spec.SchemaProps{ + Description: "TopologySpreadConstraints describes how a group of instances ought to spread across topology domains. Scheduler will schedule instances in a way which abides by the constraints. All topologySpreadConstraints are ANDed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.TopologySpreadConstraint"), + }, + }, + }, + }, + }, + "nodeRef": { + SchemaProps: spec.SchemaProps{ + Description: "NodeRef references the node hosting the load balancer instance. Will be set by the scheduler if empty.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"type", "loadBalancerType", "networkRef"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Affinity", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerPort", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.TopologySpreadConstraint", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP", "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ips": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + "collisionCount": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_InstanceTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancer(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancer is the schema for the loadbalancers API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerDestination(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerDestination is the destination of the load balancer.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP is the target IP.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + "targetRef": { + SchemaProps: spec.SchemaProps{ + Description: "TargetRef is the target providing the destination.", + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerTargetRef"), + }, + }, + }, + Required: []string{"ip"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerTargetRef", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerIP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of the load balancer IP.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ipFamily": { + SchemaProps: spec.SchemaProps{ + Description: "IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, will be defaulted by using the IP family of IP. If only IPFamily is specified, a random IP of that family will be allocated if possible.\n\nPossible enum values:\n - `\"IPv4\"` indicates that this IP is IPv4 protocol\n - `\"IPv6\"` indicates that this IP is IPv6 protocol", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"IPv4", "IPv6"}, + }, + }, + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerList contains a list of LoadBalancer.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancer"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancer", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerPort(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "protocol": { + SchemaProps: spec.SchemaProps{ + Description: "Protocol is the protocol the load balancer should allow. If not specified, defaults to TCP.\n\nPossible enum values:\n - `\"SCTP\"` is the SCTP protocol.\n - `\"TCP\"` is the TCP protocol.\n - `\"UDP\"` is the UDP protocol.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"SCTP", "TCP", "UDP"}, + }, + }, + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Port is the port to allow.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "endPort": { + SchemaProps: spec.SchemaProps{ + Description: "EndPort marks the end of the port range to allow. If unspecified, only a single port, Port, will be allowed.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"port"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerRouting(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerRouting is the schema for the loadbalancerroutings API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "ips": { + SchemaProps: spec.SchemaProps{ + Description: "IPs are the IPs the routing is for.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + "destinations": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerDestination"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerDestination", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerRoutingList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerRoutingList contains a list of LoadBalancerRouting.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerRouting"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerRouting", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type specifies the type of load balancer.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "networkRef": { + SchemaProps: spec.SchemaProps{ + Description: "NetworkRef references the network the load balancer is part of.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "ips": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "IPs specifies the IPs of the load balancer.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerIP"), + }, + }, + }, + }, + }, + "ports": { + SchemaProps: spec.SchemaProps{ + Description: "Ports are the ports the load balancer should allow. If empty, the load balancer allows all ports.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerPort"), + }, + }, + }, + }, + }, + "nodeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "Selector selects all Instance that are managed by this daemon set.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "template": { + SchemaProps: spec.SchemaProps{ + Description: "Template is the instance template.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceTemplate"), + }, + }, + }, + Required: []string{"type", "networkRef", "template"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.InstanceTemplate", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerIP", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.LoadBalancerPort", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "collisionCount": { + SchemaProps: spec.SchemaProps{ + Description: "CollisionCount is used to construct names for IP addresses for the load balancer.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "ips": { + SchemaProps: spec.SchemaProps{ + Description: "IPs are the IPs used currently by the load balancer.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_LoadBalancerTargetRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerTargetRef is a load balancer target.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the UID of the target.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of the target.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "nodeRef": { + SchemaProps: spec.SchemaProps{ + Description: "NodeRef references the node the destination network interface is on.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"uid", "name", "nodeRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGateway(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATGateway is the schema for the natgateways API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewaySpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewaySpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscaler(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATGatewayAutoscaler is the schema for the natgatewayautoscalers API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscalerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATGatewayAutoscalerList contains a list of NATGatewayAutoscaler.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscaler"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayAutoscaler", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "natGatewayRef": { + SchemaProps: spec.SchemaProps{ + Description: "NATGatewayRef points to the target NATGateway to scale.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "minPublicIPs": { + SchemaProps: spec.SchemaProps{ + Description: "MinPublicIPs is the minimum number of public IPs to allocate for a NAT Gateway.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "maxPublicIPs": { + SchemaProps: spec.SchemaProps{ + Description: "MaxPublicIPs is the maximum number of public IPs to allocate for a NAT Gateway.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"natGatewayRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayAutoscalerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayIP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the semantic name of the NAT gateway IP.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATGatewayList contains a list of NATGateway.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGateway"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGateway", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewaySpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ipFamily": { + SchemaProps: spec.SchemaProps{ + Description: "IPFamily is the IP family of the NAT gateway.\n\nPossible enum values:\n - `\"IPv4\"` indicates that this IP is IPv4 protocol\n - `\"IPv6\"` indicates that this IP is IPv6 protocol", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"IPv4", "IPv6"}, + }, + }, + "networkRef": { + SchemaProps: spec.SchemaProps{ + Description: "NetworkRef references the network the NAT gateway is part of.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "ips": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "IPs specifies the IPs of the NAT gateway.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayIP"), + }, + }, + }, + }, + }, + "portsPerNetworkInterface": { + SchemaProps: spec.SchemaProps{ + Description: "PortsPerNetworkInterface specifies how many ports to allocate per network interface.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"ipFamily", "networkRef", "portsPerNetworkInterface"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATGatewayIP", "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATGatewayStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "usedNATIPs": { + SchemaProps: spec.SchemaProps{ + Description: "UsedNATIPs is the number of NAT IPs in-use.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "requestedNATIPs": { + SchemaProps: spec.SchemaProps{ + Description: "RequestedNATIPs is the number of requested NAT IPs.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATIP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP is the IP to NAT.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + "sections": { + SchemaProps: spec.SchemaProps{ + Description: "Sections are the sections of the NATIP.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIPSection"), + }, + }, + }, + }, + }, + }, + Required: []string{"ip"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIPSection", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATIPSection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP is the source IP.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Port is the start port of the section.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "endPort": { + SchemaProps: spec.SchemaProps{ + Description: "EndPort is the end port of the section", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "targetRef": { + SchemaProps: spec.SchemaProps{ + Description: "TargetRef references the entity having the IP.", + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTableIPTargetRef"), + }, + }, + }, + Required: []string{"ip", "port", "endPort"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTableIPTargetRef", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATTable(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATTable is the schema for the nattables API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "ips": { + SchemaProps: spec.SchemaProps{ + Description: "IPs specifies how to NAT the IPs for the NAT gateway.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIP"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATIP", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATTableIPTargetRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the UID of the target.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of the target.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "nodeRef": { + SchemaProps: spec.SchemaProps{ + Description: "NodeRef references the node the destination network interface is on.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"uid", "name", "nodeRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NATTableList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NATTableList contains a list of NATTable.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTable"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NATTable", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_Network(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Network is the schema for the networks API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkID(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NetworkID is the schema for the networkids API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkIDClaimRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkIDList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NetworkIDList contains a list of NetworkID.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkID"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkID", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkIDSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "claimRef": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDClaimRef"), + }, + }, + }, + Required: []string{"claimRef"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkIDClaimRef"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterface(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NetworkInterface is the schema for the networkinterfaces API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NetworkInterfaceList contains a list of NetworkInterface.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterface"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterface", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceNAT(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ipFamily": { + SchemaProps: spec.SchemaProps{ + Description: "IPFamily is the IP family of the handling NAT gateway.\n\nPossible enum values:\n - `\"IPv4\"` indicates that this IP is IPv4 protocol\n - `\"IPv6\"` indicates that this IP is IPv6 protocol", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"IPv4", "IPv6"}, + }, + }, + "claimRef": { + SchemaProps: spec.SchemaProps{ + Description: "ClaimRef references the NAT claim handling the network interface's NAT.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNATClaimRef"), + }, + }, + }, + Required: []string{"ipFamily", "claimRef"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNATClaimRef"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceNATClaimRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of the claiming NAT gateway.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the uid of the claiming NAT gateway.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "uid"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfacePublicIP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the semantic name of the network interface public IP.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ipFamily": { + SchemaProps: spec.SchemaProps{ + Description: "IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, will be defaulted by using the IP family of IP. If only IPFamily is specified, a random IP of that family will be allocated if possible.\n\nPossible enum values:\n - `\"IPv4\"` indicates that this IP is IPv4 protocol\n - `\"IPv6\"` indicates that this IP is IPv6 protocol", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"IPv4", "IPv6"}, + }, + }, + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP specifies a specific IP to allocate. If empty, a random ephemeral IP will be allocated.", + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeRef": { + SchemaProps: spec.SchemaProps{ + Description: "NodeRef is the node the network interface is hosted on.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "networkRef": { + SchemaProps: spec.SchemaProps{ + Description: "NetworkRef references the network that the network interface is in.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "ips": { + SchemaProps: spec.SchemaProps{ + Description: "IPs are the internal IPs of the network interface.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + "prefixes": { + SchemaProps: spec.SchemaProps{ + Description: "Prefixes are additional prefixes to route to the network interface.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IPPrefix"), + }, + }, + }, + }, + }, + "natGateways": { + SchemaProps: spec.SchemaProps{ + Description: "NATs specify the NAT of the network interface IP family. Can only be set if there is no matching IP family in PublicIPs.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNAT"), + }, + }, + }, + }, + }, + "publicIPs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "PublicIPs are the public IPs the network interface should have.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfacePublicIP"), + }, + }, + }, + }, + }, + }, + Required: []string{"nodeRef", "networkRef"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfaceNAT", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NetworkInterfacePublicIP", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IPPrefix", "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkInterfaceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "state": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "pciAddress": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.PCIAddress"), + }, + }, + "prefixes": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IPPrefix"), + }, + }, + }, + }, + }, + "publicIPs": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + "natIPs": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.PCIAddress", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IP", "github.com/onmetal/onmetal-api-net/apimachinery/api/net.IPPrefix"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NetworkList contains a list of Network.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Network"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Network", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "ID is the ID of the network.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NetworkStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_Node(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Node is the schema for the nodes API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSpec", "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "requiredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelector"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeList contains a list of Node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Node"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.Node", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector represents the union of the results of one or more queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeSelectorTerms": { + SchemaProps: spec.SchemaProps{ + Description: "Required. A list of node selector terms. The terms are ORed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorTerm"), + }, + }, + }, + }, + }, + }, + Required: []string{"nodeSelectorTerms"}, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorTerm"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeSelectorRequirement is a requirement for a selector. It's a combination of the key to match, the operator to match with, and zero to n values, depending on the operator.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "Key is the key the selector applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "Operator represents the key's relationship to the values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Description: "Values are the values to relate the key to via the operator.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeSelectorTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeSelectorTerm matches no objects if it's empty. The requirements of the selector are ANDed.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchExpressions": { + SchemaProps: spec.SchemaProps{ + Description: "MatchExpressions matches nodes by the label selector requirements.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorRequirement"), + }, + }, + }, + }, + }, + "matchFields": { + SchemaProps: spec.SchemaProps{ + Description: "MatchFields matches the nodes by their fields.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorRequirement"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1.NodeSelectorRequirement"}, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_NodeStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_PCIAddress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PCIAddress is a PCI address.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "domain": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "bus": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "slot": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "function": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_onmetal_api_net_api_core_v1alpha1_TopologySpreadConstraint(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TopologySpreadConstraint specifies how to spread matching instances among the given topology.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "maxSkew": { + SchemaProps: spec.SchemaProps{ + Description: "MaxSkew describes the degree to which instances may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference between the number of matching instances in the target topology and the global minimum. The global minimum is the minimum number of matching instances in an eligible domain or zero if the number of eligible domains is less than MinDomains.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "topologyKey": { + SchemaProps: spec.SchemaProps{ + Description: "TopologyKey is the key of node labels. Nodes that have a label with this key and identical values are considered to be in the same topology. We consider each as a \"bucket\", and try to put balanced number of instances into each bucket. We define a domain as a particular instance of a topology. Also, we define an eligible domain as a domain whose nodes meet the requirements of nodeAffinityPolicy and nodeTaintsPolicy.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "whenUnsatisfiable": { + SchemaProps: spec.SchemaProps{ + Description: "WhenUnsatisfiable indicates how to deal with a instance if it doesn't satisfy the spread constraint. - DoNotSchedule (default) tells the scheduler not to schedule it. - ScheduleAnyway tells the scheduler to schedule the instance in any location,\n but giving higher precedence to topologies that would help reduce the\n skew.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "LabelSelector is used to find matching instances. Instances that match this label selector are counted to determine the number of instances in their corresponding topology domain.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + }, + Required: []string{"maxSkew", "topologyKey", "whenUnsatisfiable"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_onmetal_api_net_apimachinery_api_net_IP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IP is an IP address.", + Type: net.IP{}.OpenAPISchemaType(), + Format: net.IP{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_onmetal_api_net_apimachinery_api_net_IPPrefix(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IPPrefix represents a network prefix.", + Type: net.IPPrefix{}.OpenAPISchemaType(), + Format: net.IPPrefix{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Persistent Disk resource in AWS.\n\nAn AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeID": { + SchemaProps: spec.SchemaProps{ + Description: "volumeID is unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Type: []string{"string"}, + Format: "", + }, + }, + "partition": { + SchemaProps: spec.SchemaProps{ + Description: "partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty).", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly value true will force the readOnly setting in VolumeMounts. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"volumeID"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Affinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Affinity is a group of affinity scheduling rules.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeAffinity": { + SchemaProps: spec.SchemaProps{ + Description: "Describes node affinity scheduling rules for the pod.", + Ref: ref("k8s.io/api/core/v1.NodeAffinity"), + }, + }, + "podAffinity": { + SchemaProps: spec.SchemaProps{ + Description: "Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)).", + Ref: ref("k8s.io/api/core/v1.PodAffinity"), + }, + }, + "podAntiAffinity": { + SchemaProps: spec.SchemaProps{ + Description: "Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)).", + Ref: ref("k8s.io/api/core/v1.PodAntiAffinity"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeAffinity", "k8s.io/api/core/v1.PodAffinity", "k8s.io/api/core/v1.PodAntiAffinity"}, + } +} + +func schema_k8sio_api_core_v1_AttachedVolume(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AttachedVolume describes a volume attached to a node", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the attached volume", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "devicePath": { + SchemaProps: spec.SchemaProps{ + Description: "DevicePath represents the device path where the volume should be available", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "devicePath"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_AvoidPods(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AvoidPods describes pods that should avoid this node. This is the value for a Node annotation with key scheduler.alpha.kubernetes.io/preferAvoidPods and will eventually become a field of NodeStatus.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "preferAvoidPods": { + SchemaProps: spec.SchemaProps{ + Description: "Bounded-sized list of signatures of pods that should avoid this node, sorted in timestamp order from oldest to newest. Size of the slice is unspecified.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PreferAvoidPodsEntry"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PreferAvoidPodsEntry"}, + } +} + +func schema_k8sio_api_core_v1_AzureDiskVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "diskName": { + SchemaProps: spec.SchemaProps{ + Description: "diskName is the Name of the data disk in the blob storage", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "diskURI": { + SchemaProps: spec.SchemaProps{ + Description: "diskURI is the URI of data disk in the blob storage", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "cachingMode": { + SchemaProps: spec.SchemaProps{ + Description: "cachingMode is the Host Caching mode: None, Read Only, Read Write.\n\nPossible enum values:\n - `\"None\"`\n - `\"ReadOnly\"`\n - `\"ReadWrite\"`", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"None", "ReadOnly", "ReadWrite"}, + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "kind expected values are Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared\n\nPossible enum values:\n - `\"Dedicated\"`\n - `\"Managed\"`\n - `\"Shared\"`", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Dedicated", "Managed", "Shared"}, + }, + }, + }, + Required: []string{"diskName", "diskURI"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_AzureFilePersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "secretName": { + SchemaProps: spec.SchemaProps{ + Description: "secretName is the name of secret that contains Azure Storage Account Name and Key", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "shareName": { + SchemaProps: spec.SchemaProps{ + Description: "shareName is the azure Share Name", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "secretNamespace is the namespace of the secret that contains Azure Storage Account Name and Key default is the same as the Pod", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"secretName", "shareName"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_AzureFileVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "secretName": { + SchemaProps: spec.SchemaProps{ + Description: "secretName is the name of secret that contains Azure Storage Account Name and Key", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "shareName": { + SchemaProps: spec.SchemaProps{ + Description: "shareName is the azure share Name", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"secretName", "shareName"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Binding(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Binding ties one object to another; for example, a pod is bound to a node by a scheduler. Deprecated in 1.7, please use the bindings subresource of pods instead.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "target": { + SchemaProps: spec.SchemaProps{ + Description: "The target object that you want to bind to the standard object.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + Required: []string{"target"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_CSIPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents storage that is managed by an external CSI volume driver (Beta feature)", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "driver": { + SchemaProps: spec.SchemaProps{ + Description: "driver is the name of the driver to use for this volume. Required.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeHandle": { + SchemaProps: spec.SchemaProps{ + Description: "volumeHandle is the unique volume name returned by the CSI volume plugin’s CreateVolume to refer to the volume on all subsequent calls. Required.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly value to pass to ControllerPublishVolumeRequest. Defaults to false (read/write).", + Type: []string{"boolean"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\".", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeAttributes": { + SchemaProps: spec.SchemaProps{ + Description: "volumeAttributes of the volume to publish.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "controllerPublishSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "controllerPublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerPublishVolume and ControllerUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "nodeStageSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "nodeStageSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeStageVolume and NodeStageVolume and NodeUnstageVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "nodePublishSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "nodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "controllerExpandSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "controllerExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerExpandVolume call. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "nodeExpandSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This is a beta field which is enabled default by CSINodeExpandSecret feature gate. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + }, + Required: []string{"driver", "volumeHandle"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_CSIVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a source location of a volume to mount, managed by an external CSI driver", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "driver": { + SchemaProps: spec.SchemaProps{ + Description: "driver is the name of the CSI driver that handles this volume. Consult with your admin for the correct name as registered in the cluster.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly specifies a read-only configuration for the volume. Defaults to false (read/write).", + Type: []string{"boolean"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType to mount. Ex. \"ext4\", \"xfs\", \"ntfs\". If not provided, the empty value is passed to the associated CSI driver which will determine the default filesystem to apply.", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeAttributes": { + SchemaProps: spec.SchemaProps{ + Description: "volumeAttributes stores driver-specific properties that are passed to the CSI driver. Consult your driver's documentation for supported values.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "nodePublishSecretRef": { + SchemaProps: spec.SchemaProps{ + Description: "nodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secret references are passed.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"driver"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_Capabilities(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adds and removes POSIX capabilities from running containers.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "add": { + SchemaProps: spec.SchemaProps{ + Description: "Added capabilities", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "drop": { + SchemaProps: spec.SchemaProps{ + Description: "Removed capabilities", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_CephFSPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "monitors": { + SchemaProps: spec.SchemaProps{ + Description: "monitors is Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + Type: []string{"string"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Description: "user is Optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretFile": { + SchemaProps: spec.SchemaProps{ + Description: "secretFile is Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"monitors"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_CephFSVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "monitors": { + SchemaProps: spec.SchemaProps{ + Description: "monitors is Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + Type: []string{"string"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Description: "user is optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretFile": { + SchemaProps: spec.SchemaProps{ + Description: "secretFile is Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"monitors"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_CinderPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeID": { + SchemaProps: spec.SchemaProps{ + Description: "volumeID used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is Optional: points to a secret object containing parameters used to connect to OpenStack.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + }, + Required: []string{"volumeID"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_CinderVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeID": { + SchemaProps: spec.SchemaProps{ + Description: "volumeID used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is optional: points to a secret object containing parameters used to connect to OpenStack.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"volumeID"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_ClaimSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClaimSource describes a reference to a ResourceClaim.\n\nExactly one of these fields should be set. Consumers of this type must treat an empty object as if it has an unknown value.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "resourceClaimName": { + SchemaProps: spec.SchemaProps{ + Description: "ResourceClaimName is the name of a ResourceClaim object in the same namespace as this pod.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceClaimTemplateName": { + SchemaProps: spec.SchemaProps{ + Description: "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The name of the ResourceClaim will be -, where is the PodResourceClaim.Name. Pod validation will reject the pod if the concatenated name is not valid for a ResourceClaim (e.g. too long).\n\nAn existing ResourceClaim with that name that is not owned by the pod will not be used for the pod to avoid using an unrelated resource by mistake. Scheduling and pod startup are then blocked until the unrelated ResourceClaim is removed.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ClientIPConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClientIPConfig represents the configurations of Client IP based session affinity.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "timeoutSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be >0 && <=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ComponentCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Information about the condition of a component.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of condition for a component. Valid value: \"Healthy\"", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition for a component. Valid values for \"Healthy\": \"True\", \"False\", or \"Unknown\".", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Message about the condition for a component. For example, information about a health check.", + Type: []string{"string"}, + Format: "", + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Description: "Condition error code for a component. For example, a health check error code.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ComponentStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of component conditions observed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ComponentCondition"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ComponentCondition", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ComponentStatusList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Status of all the conditions for the component as a list of ComponentStatus objects. Deprecated: This API is deprecated in v1.19+", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of ComponentStatus objects.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ComponentStatus"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ComponentStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ConfigMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ConfigMap holds configuration data for pods to consume.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "immutable": { + SchemaProps: spec.SchemaProps{ + Description: "Immutable, if set to true, ensures that data stored in the ConfigMap cannot be updated (only object metadata can be modified). If not set to true, the field can be modified at any time. Defaulted to nil.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Description: "Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'. Values with non-UTF-8 byte sequences must use the BinaryData field. The keys stored in Data must not overlap with the keys in the BinaryData field, this is enforced during validation process.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "binaryData": { + SchemaProps: spec.SchemaProps{ + Description: "BinaryData contains the binary data. Each key must consist of alphanumeric characters, '-', '_' or '.'. BinaryData can contain byte sequences that are not in the UTF-8 range. The keys stored in BinaryData must not overlap with the ones in the Data field, this is enforced during validation process. Using this field will require 1.10+ apiserver and kubelet.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "byte", + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ConfigMapEnvSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "Specify whether the ConfigMap must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ConfigMapKeySelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Selects a key from a ConfigMap.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "key": { + SchemaProps: spec.SchemaProps{ + Description: "The key to select.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "Specify whether the ConfigMap or its key must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"key"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ConfigMapList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ConfigMapList is a resource containing a list of ConfigMap objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is the list of ConfigMaps.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ConfigMap"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ConfigMap", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ConfigMapNodeConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ConfigMapNodeConfigSource contains the information to reference a ConfigMap as a config source for the Node. This API is deprecated since 1.22: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace is the metadata.namespace of the referenced ConfigMap. This field is required in all cases.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the metadata.name of the referenced ConfigMap. This field is required in all cases.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the metadata.UID of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "ResourceVersion is the metadata.ResourceVersion of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.", + Type: []string{"string"}, + Format: "", + }, + }, + "kubeletConfigKey": { + SchemaProps: spec.SchemaProps{ + Description: "KubeletConfigKey declares which key of the referenced ConfigMap corresponds to the KubeletConfiguration structure This field is required in all cases.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"namespace", "name", "kubeletConfigKey"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ConfigMapProjection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adapts a ConfigMap into a projected volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a projected volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. Note that this is identical to a configmap volume source without the default mode.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items if unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.KeyToPath"), + }, + }, + }, + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "optional specify whether the ConfigMap or its keys must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.KeyToPath"}, + } +} + +func schema_k8sio_api_core_v1_ConfigMapVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adapts a ConfigMap into a volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items if unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.KeyToPath"), + }, + }, + }, + }, + }, + "defaultMode": { + SchemaProps: spec.SchemaProps{ + Description: "defaultMode is optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "optional specify whether the ConfigMap or its keys must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.KeyToPath"}, + } +} + +func schema_k8sio_api_core_v1_Container(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A single application container that you want to run within a pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.", + Type: []string{"string"}, + Format: "", + }, + }, + "command": { + SchemaProps: spec.SchemaProps{ + Description: "Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "args": { + SchemaProps: spec.SchemaProps{ + Description: "Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "workingDir": { + SchemaProps: spec.SchemaProps{ + Description: "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "ports": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "containerPort", + "protocol", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "containerPort", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of ports to expose from the container. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default \"0.0.0.0\" address inside a container will be accessible from the network. Modifying this array with strategic merge patch may corrupt the data. For more information See https://github.com/kubernetes/kubernetes/issues/108255. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerPort"), + }, + }, + }, + }, + }, + "envFrom": { + SchemaProps: spec.SchemaProps{ + Description: "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvFromSource"), + }, + }, + }, + }, + }, + "env": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of environment variables to set in the container. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvVar"), + }, + }, + }, + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + "resizePolicy": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Resources resize policy for the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerResizePolicy"), + }, + }, + }, + }, + }, + "volumeMounts": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Pod volumes to mount into the container's filesystem. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeMount"), + }, + }, + }, + }, + }, + "volumeDevices": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "devicePath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "volumeDevices is the list of block devices to be used by the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeDevice"), + }, + }, + }, + }, + }, + "livenessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "readinessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "startupProbe": { + SchemaProps: spec.SchemaProps{ + Description: "StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "lifecycle": { + SchemaProps: spec.SchemaProps{ + Description: "Actions that the management system should take in response to container lifecycle events. Cannot be updated.", + Ref: ref("k8s.io/api/core/v1.Lifecycle"), + }, + }, + "terminationMessagePath": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "terminationMessagePolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.\n\nPossible enum values:\n - `\"FallbackToLogsOnError\"` will read the most recent contents of the container logs for the container status message when the container exits with an error and the terminationMessagePath has no contents.\n - `\"File\"` is the default behavior and will set the container status message to the contents of the container's terminationMessagePath when the container exits.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"FallbackToLogsOnError", "File"}, + }, + }, + "imagePullPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images\n\nPossible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Always", "IfNotPresent", "Never"}, + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/", + Ref: ref("k8s.io/api/core/v1.SecurityContext"), + }, + }, + "stdin": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stdinOnce": { + SchemaProps: spec.SchemaProps{ + Description: "Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tty": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.ContainerResizePolicy", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount"}, + } +} + +func schema_k8sio_api_core_v1_ContainerImage(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Describe a container image", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "names": { + SchemaProps: spec.SchemaProps{ + Description: "Names by which this image is known. e.g. [\"kubernetes.example/hyperkube:v1.0.7\", \"cloud-vendor.registry.example/cloud-vendor/hyperkube:v1.0.7\"]", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "sizeBytes": { + SchemaProps: spec.SchemaProps{ + Description: "The size of the image in bytes.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ContainerPort(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerPort represents a network port in a single container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services.", + Type: []string{"string"}, + Format: "", + }, + }, + "hostPort": { + SchemaProps: spec.SchemaProps{ + Description: "Number of port to expose on the host. If specified, this must be a valid port number, 0 < x < 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "containerPort": { + SchemaProps: spec.SchemaProps{ + Description: "Number of port to expose on the pod's IP address. This must be a valid port number, 0 < x < 65536.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "protocol": { + SchemaProps: spec.SchemaProps{ + Description: "Protocol for port. Must be UDP, TCP, or SCTP. Defaults to \"TCP\".\n\nPossible enum values:\n - `\"SCTP\"` is the SCTP protocol.\n - `\"TCP\"` is the TCP protocol.\n - `\"UDP\"` is the UDP protocol.", + Default: "TCP", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"SCTP", "TCP", "UDP"}, + }, + }, + "hostIP": { + SchemaProps: spec.SchemaProps{ + Description: "What host IP to bind the external port to.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"containerPort"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ContainerResizePolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerResizePolicy represents resource resize policy for the container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "resourceName": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the resource to which this resource resize policy applies. Supported values: cpu, memory.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "restartPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Restart policy to apply when specified resource is resized. If not specified, it defaults to NotRequired.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"resourceName", "restartPolicy"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ContainerState(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerState holds a possible state of container. Only one of its members may be specified. If none of them is specified, the default one is ContainerStateWaiting.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "waiting": { + SchemaProps: spec.SchemaProps{ + Description: "Details about a waiting container", + Ref: ref("k8s.io/api/core/v1.ContainerStateWaiting"), + }, + }, + "running": { + SchemaProps: spec.SchemaProps{ + Description: "Details about a running container", + Ref: ref("k8s.io/api/core/v1.ContainerStateRunning"), + }, + }, + "terminated": { + SchemaProps: spec.SchemaProps{ + Description: "Details about a terminated container", + Ref: ref("k8s.io/api/core/v1.ContainerStateTerminated"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerStateRunning", "k8s.io/api/core/v1.ContainerStateTerminated", "k8s.io/api/core/v1.ContainerStateWaiting"}, + } +} + +func schema_k8sio_api_core_v1_ContainerStateRunning(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerStateRunning is a running state of a container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "startedAt": { + SchemaProps: spec.SchemaProps{ + Description: "Time at which the container was last (re-)started", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_ContainerStateTerminated(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerStateTerminated is a terminated state of a container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "exitCode": { + SchemaProps: spec.SchemaProps{ + Description: "Exit status from the last termination of the container", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "signal": { + SchemaProps: spec.SchemaProps{ + Description: "Signal from the last termination of the container", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) reason from the last termination of the container", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Message regarding the last termination of the container", + Type: []string{"string"}, + Format: "", + }, + }, + "startedAt": { + SchemaProps: spec.SchemaProps{ + Description: "Time at which previous execution of the container started", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "finishedAt": { + SchemaProps: spec.SchemaProps{ + Description: "Time at which the container last terminated", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "containerID": { + SchemaProps: spec.SchemaProps{ + Description: "Container's ID in the format '://'", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"exitCode"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_ContainerStateWaiting(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerStateWaiting is a waiting state of a container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) reason the container is not yet running.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Message regarding why the container is not yet running.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ContainerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ContainerStatus contains details for the current status of this container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is a DNS_LABEL representing the unique name of the container. Each container in a pod must have a unique name across all container types. Cannot be updated.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "state": { + SchemaProps: spec.SchemaProps{ + Description: "State holds details about the container's current condition.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerState"), + }, + }, + "lastState": { + SchemaProps: spec.SchemaProps{ + Description: "LastTerminationState holds the last termination state of the container to help debug container crashes and restarts. This field is not populated if the container is still running and RestartCount is 0.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerState"), + }, + }, + "ready": { + SchemaProps: spec.SchemaProps{ + Description: "Ready specifies whether the container is currently passing its readiness check. The value will change as readiness probes keep executing. If no readiness probes are specified, this field defaults to true once the container is fully started (see Started field).\n\nThe value is typically used to determine whether a container is ready to accept traffic.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "restartCount": { + SchemaProps: spec.SchemaProps{ + Description: "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "Image is the name of container image that the container is running. The container image may not match the image used in the PodSpec, as it may have been resolved by the runtime. More info: https://kubernetes.io/docs/concepts/containers/images.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "imageID": { + SchemaProps: spec.SchemaProps{ + Description: "ImageID is the image ID of the container's image. The image ID may not match the image ID of the image used in the PodSpec, as it may have been resolved by the runtime.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "containerID": { + SchemaProps: spec.SchemaProps{ + Description: "ContainerID is the ID of the container in the format '://'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").", + Type: []string{"string"}, + Format: "", + }, + }, + "started": { + SchemaProps: spec.SchemaProps{ + Description: "Started indicates whether the container has finished its postStart lifecycle hook and passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. In both cases, startup probes will run again. Is always true when no startupProbe is defined and container is running and has passed the postStart lifecycle hook. The null value must be treated the same as false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "allocatedResources": { + SchemaProps: spec.SchemaProps{ + Description: "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized.", + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + }, + Required: []string{"name", "ready", "restartCount", "image", "imageID"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerState", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_DaemonEndpoint(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DaemonEndpoint contains information about a single Daemon endpoint.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Port": { + SchemaProps: spec.SchemaProps{ + Description: "Port number of the given endpoint.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"Port"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_DownwardAPIProjection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents downward API info for projecting into a projected volume. Note that this is identical to a downwardAPI volume source without the default mode.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of DownwardAPIVolume file", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.DownwardAPIVolumeFile"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.DownwardAPIVolumeFile"}, + } +} + +func schema_k8sio_api_core_v1_DownwardAPIVolumeFile(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DownwardAPIVolumeFile represents information to create the file containing the pod field", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldRef": { + SchemaProps: spec.SchemaProps{ + Description: "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.", + Ref: ref("k8s.io/api/core/v1.ObjectFieldSelector"), + }, + }, + "resourceFieldRef": { + SchemaProps: spec.SchemaProps{ + Description: "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.", + Ref: ref("k8s.io/api/core/v1.ResourceFieldSelector"), + }, + }, + "mode": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"path"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectFieldSelector", "k8s.io/api/core/v1.ResourceFieldSelector"}, + } +} + +func schema_k8sio_api_core_v1_DownwardAPIVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DownwardAPIVolumeSource represents a volume containing downward API info. Downward API volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of downward API volume file", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.DownwardAPIVolumeFile"), + }, + }, + }, + }, + }, + "defaultMode": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: mode bits to use on created files by default. Must be a Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.DownwardAPIVolumeFile"}, + } +} + +func schema_k8sio_api_core_v1_EmptyDirVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents an empty directory for a pod. Empty directory volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "medium": { + SchemaProps: spec.SchemaProps{ + Description: "medium represents what type of storage medium should back this directory. The default is \"\" which means to use the node's default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + Type: []string{"string"}, + Format: "", + }, + }, + "sizeLimit": { + SchemaProps: spec.SchemaProps{ + Description: "sizeLimit is the total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_EndpointAddress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EndpointAddress is a tuple that describes single IP address.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "The IP of this endpoint. May not be loopback (127.0.0.0/8 or ::1), link-local (169.254.0.0/16 or fe80::/10), or link-local multicast (224.0.0.0/24 or ff02::/16).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "hostname": { + SchemaProps: spec.SchemaProps{ + Description: "The Hostname of this endpoint", + Type: []string{"string"}, + Format: "", + }, + }, + "nodeName": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Node hosting this endpoint. This can be used to determine endpoints local to a node.", + Type: []string{"string"}, + Format: "", + }, + }, + "targetRef": { + SchemaProps: spec.SchemaProps{ + Description: "Reference to object providing the endpoint.", + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + Required: []string{"ip"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_EndpointPort(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EndpointPort is a tuple that describes a single port.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "The name of this port. This must match the 'name' field in the corresponding ServicePort. Must be a DNS_LABEL. Optional only if one port is defined.", + Type: []string{"string"}, + Format: "", + }, + }, + "port": { + SchemaProps: spec.SchemaProps{ + Description: "The port number of the endpoint.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "protocol": { + SchemaProps: spec.SchemaProps{ + Description: "The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.\n\nPossible enum values:\n - `\"SCTP\"` is the SCTP protocol.\n - `\"TCP\"` is the TCP protocol.\n - `\"UDP\"` is the UDP protocol.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"SCTP", "TCP", "UDP"}, + }, + }, + "appProtocol": { + SchemaProps: spec.SchemaProps{ + Description: "The application protocol for this port. This is used as a hint for implementations to offer richer behavior for protocols that they understand. This field follows standard Kubernetes label syntax. Valid values are either:\n\n* Un-prefixed protocol names - reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names).\n\n* Kubernetes-defined prefixed names:\n * 'kubernetes.io/h2c' - HTTP/2 over cleartext as described in https://www.rfc-editor.org/rfc/rfc7540\n\n* Other protocols should use implementation-defined prefixed names such as mycompany.com/my-custom-protocol.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"port"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_EndpointSubset(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n\n\t{\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t}\n\nThe resulting set of endpoints can be viewed as:\n\n\ta: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n\tb: [ 10.10.1.1:309, 10.10.2.2:309 ]", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "addresses": { + SchemaProps: spec.SchemaProps{ + Description: "IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EndpointAddress"), + }, + }, + }, + }, + }, + "notReadyAddresses": { + SchemaProps: spec.SchemaProps{ + Description: "IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EndpointAddress"), + }, + }, + }, + }, + }, + "ports": { + SchemaProps: spec.SchemaProps{ + Description: "Port numbers available on the related IP addresses.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EndpointPort"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.EndpointAddress", "k8s.io/api/core/v1.EndpointPort"}, + } +} + +func schema_k8sio_api_core_v1_Endpoints(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Endpoints is a collection of endpoints that implement the actual service. Example:\n\n\t Name: \"mysvc\",\n\t Subsets: [\n\t {\n\t Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t },\n\t {\n\t Addresses: [{\"ip\": \"10.10.3.3\"}],\n\t Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n\t },\n\t]", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "subsets": { + SchemaProps: spec.SchemaProps{ + Description: "The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EndpointSubset"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.EndpointSubset", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_EndpointsList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EndpointsList is a list of endpoints.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of endpoints.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Endpoints"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Endpoints", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_EnvFromSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EnvFromSource represents the source of a set of ConfigMaps", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "prefix": { + SchemaProps: spec.SchemaProps{ + Description: "An optional identifier to prepend to each key in the ConfigMap. Must be a C_IDENTIFIER.", + Type: []string{"string"}, + Format: "", + }, + }, + "configMapRef": { + SchemaProps: spec.SchemaProps{ + Description: "The ConfigMap to select from", + Ref: ref("k8s.io/api/core/v1.ConfigMapEnvSource"), + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "The Secret to select from", + Ref: ref("k8s.io/api/core/v1.SecretEnvSource"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ConfigMapEnvSource", "k8s.io/api/core/v1.SecretEnvSource"}, + } +} + +func schema_k8sio_api_core_v1_EnvVar(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EnvVar represents an environment variable present in a Container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the environment variable. Must be a C_IDENTIFIER.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to \"\".", + Type: []string{"string"}, + Format: "", + }, + }, + "valueFrom": { + SchemaProps: spec.SchemaProps{ + Description: "Source for the environment variable's value. Cannot be used if value is not empty.", + Ref: ref("k8s.io/api/core/v1.EnvVarSource"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.EnvVarSource"}, + } +} + +func schema_k8sio_api_core_v1_EnvVarSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EnvVarSource represents a source for the value of an EnvVar.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "fieldRef": { + SchemaProps: spec.SchemaProps{ + Description: "Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.", + Ref: ref("k8s.io/api/core/v1.ObjectFieldSelector"), + }, + }, + "resourceFieldRef": { + SchemaProps: spec.SchemaProps{ + Description: "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.", + Ref: ref("k8s.io/api/core/v1.ResourceFieldSelector"), + }, + }, + "configMapKeyRef": { + SchemaProps: spec.SchemaProps{ + Description: "Selects a key of a ConfigMap.", + Ref: ref("k8s.io/api/core/v1.ConfigMapKeySelector"), + }, + }, + "secretKeyRef": { + SchemaProps: spec.SchemaProps{ + Description: "Selects a key of a secret in the pod's namespace", + Ref: ref("k8s.io/api/core/v1.SecretKeySelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ConfigMapKeySelector", "k8s.io/api/core/v1.ObjectFieldSelector", "k8s.io/api/core/v1.ResourceFieldSelector", "k8s.io/api/core/v1.SecretKeySelector"}, + } +} + +func schema_k8sio_api_core_v1_EphemeralContainer(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "An EphemeralContainer is a temporary container that you may add to an existing Pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a Pod is removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the Pod to exceed its resource allocation.\n\nTo add an ephemeral container, use the ephemeralcontainers subresource of an existing Pod. Ephemeral containers may not be removed or restarted.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the ephemeral container specified as a DNS_LABEL. This name must be unique among all containers, init containers and ephemeral containers.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images", + Type: []string{"string"}, + Format: "", + }, + }, + "command": { + SchemaProps: spec.SchemaProps{ + Description: "Entrypoint array. Not executed within a shell. The image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "args": { + SchemaProps: spec.SchemaProps{ + Description: "Arguments to the entrypoint. The image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "workingDir": { + SchemaProps: spec.SchemaProps{ + Description: "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "ports": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "containerPort", + "protocol", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "containerPort", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Ports are not allowed for ephemeral containers.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerPort"), + }, + }, + }, + }, + }, + "envFrom": { + SchemaProps: spec.SchemaProps{ + Description: "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvFromSource"), + }, + }, + }, + }, + }, + "env": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of environment variables to set in the container. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvVar"), + }, + }, + }, + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources already allocated to the pod.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + "resizePolicy": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Resources resize policy for the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerResizePolicy"), + }, + }, + }, + }, + }, + "volumeMounts": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Pod volumes to mount into the container's filesystem. Subpath mounts are not allowed for ephemeral containers. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeMount"), + }, + }, + }, + }, + }, + "volumeDevices": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "devicePath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "volumeDevices is the list of block devices to be used by the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeDevice"), + }, + }, + }, + }, + }, + "livenessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "readinessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "startupProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "lifecycle": { + SchemaProps: spec.SchemaProps{ + Description: "Lifecycle is not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Lifecycle"), + }, + }, + "terminationMessagePath": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "terminationMessagePolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.\n\nPossible enum values:\n - `\"FallbackToLogsOnError\"` will read the most recent contents of the container logs for the container status message when the container exits with an error and the terminationMessagePath has no contents.\n - `\"File\"` is the default behavior and will set the container status message to the contents of the container's terminationMessagePath when the container exits.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"FallbackToLogsOnError", "File"}, + }, + }, + "imagePullPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images\n\nPossible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Always", "IfNotPresent", "Never"}, + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: SecurityContext defines the security options the ephemeral container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.", + Ref: ref("k8s.io/api/core/v1.SecurityContext"), + }, + }, + "stdin": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stdinOnce": { + SchemaProps: spec.SchemaProps{ + Description: "Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tty": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "targetContainerName": { + SchemaProps: spec.SchemaProps{ + Description: "If set, the name of the container from PodSpec that this ephemeral container targets. The ephemeral container will be run in the namespaces (IPC, PID, etc) of this container. If not set then the ephemeral container uses the namespaces configured in the Pod spec.\n\nThe container runtime must implement support for this feature. If the runtime does not support namespace targeting then the result of setting this field is undefined.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.ContainerResizePolicy", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount"}, + } +} + +func schema_k8sio_api_core_v1_EphemeralContainerCommon(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EphemeralContainerCommon is a copy of all fields in Container to be inlined in EphemeralContainer. This separate type allows easy conversion from EphemeralContainer to Container and allows separate documentation for the fields of EphemeralContainer. When a new field is added to Container it must be added here as well.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the ephemeral container specified as a DNS_LABEL. This name must be unique among all containers, init containers and ephemeral containers.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images", + Type: []string{"string"}, + Format: "", + }, + }, + "command": { + SchemaProps: spec.SchemaProps{ + Description: "Entrypoint array. Not executed within a shell. The image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "args": { + SchemaProps: spec.SchemaProps{ + Description: "Arguments to the entrypoint. The image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "workingDir": { + SchemaProps: spec.SchemaProps{ + Description: "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "ports": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "containerPort", + "protocol", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "containerPort", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Ports are not allowed for ephemeral containers.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerPort"), + }, + }, + }, + }, + }, + "envFrom": { + SchemaProps: spec.SchemaProps{ + Description: "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvFromSource"), + }, + }, + }, + }, + }, + "env": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of environment variables to set in the container. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EnvVar"), + }, + }, + }, + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources already allocated to the pod.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + "resizePolicy": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Resources resize policy for the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerResizePolicy"), + }, + }, + }, + }, + }, + "volumeMounts": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Pod volumes to mount into the container's filesystem. Subpath mounts are not allowed for ephemeral containers. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeMount"), + }, + }, + }, + }, + }, + "volumeDevices": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "devicePath", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "volumeDevices is the list of block devices to be used by the container.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeDevice"), + }, + }, + }, + }, + }, + "livenessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "readinessProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "startupProbe": { + SchemaProps: spec.SchemaProps{ + Description: "Probes are not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Probe"), + }, + }, + "lifecycle": { + SchemaProps: spec.SchemaProps{ + Description: "Lifecycle is not allowed for ephemeral containers.", + Ref: ref("k8s.io/api/core/v1.Lifecycle"), + }, + }, + "terminationMessagePath": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.", + Type: []string{"string"}, + Format: "", + }, + }, + "terminationMessagePolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.\n\nPossible enum values:\n - `\"FallbackToLogsOnError\"` will read the most recent contents of the container logs for the container status message when the container exits with an error and the terminationMessagePath has no contents.\n - `\"File\"` is the default behavior and will set the container status message to the contents of the container's terminationMessagePath when the container exits.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"FallbackToLogsOnError", "File"}, + }, + }, + "imagePullPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images\n\nPossible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Always", "IfNotPresent", "Never"}, + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: SecurityContext defines the security options the ephemeral container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.", + Ref: ref("k8s.io/api/core/v1.SecurityContext"), + }, + }, + "stdin": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stdinOnce": { + SchemaProps: spec.SchemaProps{ + Description: "Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tty": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.ContainerResizePolicy", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount"}, + } +} + +func schema_k8sio_api_core_v1_EphemeralVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents an ephemeral volume that is handled by a normal storage driver.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeClaimTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "Will be used to create a stand-alone PVC to provision the volume. The pod in which this EphemeralVolumeSource is embedded will be the owner of the PVC, i.e. the PVC will be deleted together with the pod. The name of the PVC will be `-` where `` is the name from the `PodSpec.Volumes` array entry. Pod validation will reject the pod if the concatenated name is not valid for a PVC (for example, too long).\n\nAn existing PVC with that name that is not owned by the pod will *not* be used for the pod to avoid using an unrelated volume by mistake. Starting the pod is then blocked until the unrelated PVC is removed. If such a pre-created PVC is meant to be used by the pod, the PVC has to updated with an owner reference to the pod once the pod exists. Normally this should not be necessary, but it may be useful when manually reconstructing a broken cluster.\n\nThis field is read-only and no changes will be made by Kubernetes to the PVC after it has been created.\n\nRequired, must not be nil.", + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimTemplate"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeClaimTemplate"}, + } +} + +func schema_k8sio_api_core_v1_Event(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Event is a report of an event somewhere in the cluster. Events have a limited retention time and triggers and messages may evolve with time. Event consumers should not rely on the timing of an event with a given Reason reflecting a consistent underlying trigger, or the continued existence of events with that Reason. Events should be treated as informative, best-effort, supplemental data.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "involvedObject": { + SchemaProps: spec.SchemaProps{ + Description: "The object that this event is about.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "This should be a short, machine understandable string that gives the reason for the transition into the object's current status.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human-readable description of the status of this operation.", + Type: []string{"string"}, + Format: "", + }, + }, + "source": { + SchemaProps: spec.SchemaProps{ + Description: "The component reporting this event. Should be a short machine understandable string.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EventSource"), + }, + }, + "firstTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "lastTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "The time at which the most recent occurrence of this event was recorded.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "count": { + SchemaProps: spec.SchemaProps{ + Description: "The number of times this event has occurred.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of this event (Normal, Warning), new types could be added in the future", + Type: []string{"string"}, + Format: "", + }, + }, + "eventTime": { + SchemaProps: spec.SchemaProps{ + Description: "Time when this Event was first observed.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime"), + }, + }, + "series": { + SchemaProps: spec.SchemaProps{ + Description: "Data about the Event series this event represents or nil if it's a singleton Event.", + Ref: ref("k8s.io/api/core/v1.EventSeries"), + }, + }, + "action": { + SchemaProps: spec.SchemaProps{ + Description: "What action was taken/failed regarding to the Regarding object.", + Type: []string{"string"}, + Format: "", + }, + }, + "related": { + SchemaProps: spec.SchemaProps{ + Description: "Optional secondary object for more complex actions.", + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + "reportingComponent": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "reportingInstance": { + SchemaProps: spec.SchemaProps{ + Description: "ID of the controller instance, e.g. `kubelet-xyzf`.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"metadata", "involvedObject"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.EventSeries", "k8s.io/api/core/v1.EventSource", "k8s.io/api/core/v1.ObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_EventList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EventList is a list of events.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of events", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Event"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Event", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_EventSeries(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EventSeries contain information on series of events, i.e. thing that was/is happening continuously for some time.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "count": { + SchemaProps: spec.SchemaProps{ + Description: "Number of occurrences in this series up to the last heartbeat time", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "lastObservedTime": { + SchemaProps: spec.SchemaProps{ + Description: "Time of the last occurrence observed", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime"}, + } +} + +func schema_k8sio_api_core_v1_EventSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EventSource contains information for an event.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "component": { + SchemaProps: spec.SchemaProps{ + Description: "Component from which the event is generated.", + Type: []string{"string"}, + Format: "", + }, + }, + "host": { + SchemaProps: spec.SchemaProps{ + Description: "Node name on which the event is generated.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ExecAction(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ExecAction describes a \"run in container\" action.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "command": { + SchemaProps: spec.SchemaProps{ + Description: "Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_FCVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "targetWWNs": { + SchemaProps: spec.SchemaProps{ + Description: "targetWWNs is Optional: FC target worldwide names (WWNs)", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "lun": { + SchemaProps: spec.SchemaProps{ + Description: "lun is Optional: FC target lun number", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "wwids": { + SchemaProps: spec.SchemaProps{ + Description: "wwids Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_FlexPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "driver": { + SchemaProps: spec.SchemaProps{ + Description: "driver is the name of the driver to use for this volume.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "options is Optional: this field holds extra command options if any.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"driver"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_FlexVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "driver": { + SchemaProps: spec.SchemaProps{ + Description: "driver is the name of the driver to use for this volume.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is Optional: secretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly is Optional: defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "options is Optional: this field holds extra command options if any.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"driver"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_FlockerVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Flocker volume mounted by the Flocker agent. One and only one of datasetName and datasetUUID should be set. Flocker volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "datasetName": { + SchemaProps: spec.SchemaProps{ + Description: "datasetName is Name of the dataset stored as metadata -> name on the dataset for Flocker should be considered as deprecated", + Type: []string{"string"}, + Format: "", + }, + }, + "datasetUUID": { + SchemaProps: spec.SchemaProps{ + Description: "datasetUUID is the UUID of the dataset. This is unique identifier of a Flocker dataset", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_GCEPersistentDiskVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Persistent Disk resource in Google Compute Engine.\n\nA GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pdName": { + SchemaProps: spec.SchemaProps{ + Description: "pdName is unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Type: []string{"string"}, + Format: "", + }, + }, + "partition": { + SchemaProps: spec.SchemaProps{ + Description: "partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"pdName"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_GRPCAction(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Port number of the gRPC service. Number must be in the range 1 to 65535.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "service": { + SchemaProps: spec.SchemaProps{ + Description: "Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).\n\nIf this is not specified, the default behavior is defined by gRPC.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"port"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_GitRepoVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "repository": { + SchemaProps: spec.SchemaProps{ + Description: "repository is the URL", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "revision": { + SchemaProps: spec.SchemaProps{ + Description: "revision is the commit hash for the specified revision.", + Type: []string{"string"}, + Format: "", + }, + }, + "directory": { + SchemaProps: spec.SchemaProps{ + Description: "directory is the target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"repository"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_GlusterfsPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "endpoints": { + SchemaProps: spec.SchemaProps{ + Description: "endpoints is the endpoint name that details Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is the Glusterfs volume path. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Type: []string{"boolean"}, + Format: "", + }, + }, + "endpointsNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "endpointsNamespace is the namespace that contains Glusterfs endpoint. If this field is empty, the EndpointNamespace defaults to the same namespace as the bound PVC. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"endpoints", "path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_GlusterfsVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "endpoints": { + SchemaProps: spec.SchemaProps{ + Description: "endpoints is the endpoint name that details Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is the Glusterfs volume path. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"endpoints", "path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_HTTPGetAction(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "HTTPGetAction describes an action based on HTTP Get requests.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Path to access on the HTTP server.", + Type: []string{"string"}, + Format: "", + }, + }, + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/util/intstr.IntOrString"), + }, + }, + "host": { + SchemaProps: spec.SchemaProps{ + Description: "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.", + Type: []string{"string"}, + Format: "", + }, + }, + "scheme": { + SchemaProps: spec.SchemaProps{ + Description: "Scheme to use for connecting to the host. Defaults to HTTP.\n\nPossible enum values:\n - `\"HTTP\"` means that the scheme used will be http://\n - `\"HTTPS\"` means that the scheme used will be https://", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"HTTP", "HTTPS"}, + }, + }, + "httpHeaders": { + SchemaProps: spec.SchemaProps{ + Description: "Custom headers to set in the request. HTTP allows repeated headers.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.HTTPHeader"), + }, + }, + }, + }, + }, + }, + Required: []string{"port"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.HTTPHeader", "k8s.io/apimachinery/pkg/util/intstr.IntOrString"}, + } +} + +func schema_k8sio_api_core_v1_HTTPHeader(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "HTTPHeader describes a custom header to be used in HTTP probes", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "The header field value", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "value"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_HostAlias(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP address of the host file entry.", + Type: []string{"string"}, + Format: "", + }, + }, + "hostnames": { + SchemaProps: spec.SchemaProps{ + Description: "Hostnames for the above IP address.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_HostPathVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a host path mapped into a pod. Host path volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type for HostPath Volume Defaults to \"\" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath\n\nPossible enum values:\n - `\"\"` For backwards compatible, leave it empty if unset\n - `\"BlockDevice\"` A block device must exist at the given path\n - `\"CharDevice\"` A character device must exist at the given path\n - `\"Directory\"` A directory must exist at the given path\n - `\"DirectoryOrCreate\"` If nothing exists at the given path, an empty directory will be created there as needed with file mode 0755, having the same group and ownership with Kubelet.\n - `\"File\"` A file must exist at the given path\n - `\"FileOrCreate\"` If nothing exists at the given path, an empty file will be created there as needed with file mode 0644, having the same group and ownership with Kubelet.\n - `\"Socket\"` A UNIX socket must exist at the given path", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"", "BlockDevice", "CharDevice", "Directory", "DirectoryOrCreate", "File", "FileOrCreate", "Socket"}, + }, + }, + }, + Required: []string{"path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ISCSIPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ISCSIPersistentVolumeSource represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "targetPortal": { + SchemaProps: spec.SchemaProps{ + Description: "targetPortal is iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "iqn": { + SchemaProps: spec.SchemaProps{ + Description: "iqn is Target iSCSI Qualified Name.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lun": { + SchemaProps: spec.SchemaProps{ + Description: "lun is iSCSI Target Lun number.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "iscsiInterface": { + SchemaProps: spec.SchemaProps{ + Description: "iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "portals": { + SchemaProps: spec.SchemaProps{ + Description: "portals is the iSCSI Target Portal List. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "chapAuthDiscovery": { + SchemaProps: spec.SchemaProps{ + Description: "chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication", + Type: []string{"boolean"}, + Format: "", + }, + }, + "chapAuthSession": { + SchemaProps: spec.SchemaProps{ + Description: "chapAuthSession defines whether support iSCSI Session CHAP authentication", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is the CHAP Secret for iSCSI target and initiator authentication", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "initiatorName": { + SchemaProps: spec.SchemaProps{ + Description: "initiatorName is the custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface : will be created for the connection.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"targetPortal", "iqn", "lun"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_ISCSIVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "targetPortal": { + SchemaProps: spec.SchemaProps{ + Description: "targetPortal is iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "iqn": { + SchemaProps: spec.SchemaProps{ + Description: "iqn is the target iSCSI Qualified Name.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lun": { + SchemaProps: spec.SchemaProps{ + Description: "lun represents iSCSI Target Lun number.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "iscsiInterface": { + SchemaProps: spec.SchemaProps{ + Description: "iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "portals": { + SchemaProps: spec.SchemaProps{ + Description: "portals is the iSCSI Target Portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "chapAuthDiscovery": { + SchemaProps: spec.SchemaProps{ + Description: "chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication", + Type: []string{"boolean"}, + Format: "", + }, + }, + "chapAuthSession": { + SchemaProps: spec.SchemaProps{ + Description: "chapAuthSession defines whether support iSCSI Session CHAP authentication", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is the CHAP Secret for iSCSI target and initiator authentication", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "initiatorName": { + SchemaProps: spec.SchemaProps{ + Description: "initiatorName is the custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface : will be created for the connection.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"targetPortal", "iqn", "lun"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_KeyToPath(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Maps a string key to a path within a volume.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "key is the key to project.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "mode": { + SchemaProps: spec.SchemaProps{ + Description: "mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"key", "path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Lifecycle(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "postStart": { + SchemaProps: spec.SchemaProps{ + Description: "PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + Ref: ref("k8s.io/api/core/v1.LifecycleHandler"), + }, + }, + "preStop": { + SchemaProps: spec.SchemaProps{ + Description: "PreStop is called immediately before a container is terminated due to an API request or management event such as liveness/startup probe failure, preemption, resource contention, etc. The handler is not called if the container crashes or exits. The Pod's termination grace period countdown begins before the PreStop hook is executed. Regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period (unless delayed by finalizers). Other management of the container blocks until the hook completes or until the termination grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + Ref: ref("k8s.io/api/core/v1.LifecycleHandler"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LifecycleHandler"}, + } +} + +func schema_k8sio_api_core_v1_LifecycleHandler(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LifecycleHandler defines a specific action that should be taken in a lifecycle hook. One and only one of the fields, except TCPSocket must be specified.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "exec": { + SchemaProps: spec.SchemaProps{ + Description: "Exec specifies the action to take.", + Ref: ref("k8s.io/api/core/v1.ExecAction"), + }, + }, + "httpGet": { + SchemaProps: spec.SchemaProps{ + Description: "HTTPGet specifies the http request to perform.", + Ref: ref("k8s.io/api/core/v1.HTTPGetAction"), + }, + }, + "tcpSocket": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept for the backward compatibility. There are no validation of this field and lifecycle hooks will fail in runtime when tcp handler is specified.", + Ref: ref("k8s.io/api/core/v1.TCPSocketAction"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ExecAction", "k8s.io/api/core/v1.HTTPGetAction", "k8s.io/api/core/v1.TCPSocketAction"}, + } +} + +func schema_k8sio_api_core_v1_LimitRange(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LimitRange sets resource usage limits for each kind of resource in a Namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the limits enforced. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LimitRangeSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LimitRangeSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_LimitRangeItem(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LimitRangeItem defines a min/max usage limit for any resource that matches on kind.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of resource that this limit applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "max": { + SchemaProps: spec.SchemaProps{ + Description: "Max usage constraints on this kind by resource name.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "min": { + SchemaProps: spec.SchemaProps{ + Description: "Min usage constraints on this kind by resource name.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "default": { + SchemaProps: spec.SchemaProps{ + Description: "Default resource requirement limit value by resource name if resource limit is omitted.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "defaultRequest": { + SchemaProps: spec.SchemaProps{ + Description: "DefaultRequest is the default resource requirement request value by resource name if resource request is omitted.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "maxLimitRequestRatio": { + SchemaProps: spec.SchemaProps{ + Description: "MaxLimitRequestRatio if specified, the named resource must have a request and limit that are both non-zero where limit divided by request is less than or equal to the enumerated value; this represents the max burst for the named resource.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + }, + Required: []string{"type"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_LimitRangeList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LimitRangeList is a list of LimitRange items.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of LimitRange objects. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LimitRange"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LimitRange", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_LimitRangeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LimitRangeSpec defines a min/max usage limit for resources that match on kind.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "limits": { + SchemaProps: spec.SchemaProps{ + Description: "Limits is the list of LimitRangeItem objects that are enforced.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LimitRangeItem"), + }, + }, + }, + }, + }, + }, + Required: []string{"limits"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LimitRangeItem"}, + } +} + +func schema_k8sio_api_core_v1_List(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "List holds a list of objects, which may not be known by the server.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + +func schema_k8sio_api_core_v1_LoadBalancerIngress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerIngress represents the status of a load-balancer ingress point: traffic intended for the service should be sent to an ingress point.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)", + Type: []string{"string"}, + Format: "", + }, + }, + "hostname": { + SchemaProps: spec.SchemaProps{ + Description: "Hostname is set for load-balancer ingress points that are DNS based (typically AWS load-balancers)", + Type: []string{"string"}, + Format: "", + }, + }, + "ports": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Ports is a list of records of service ports If used, every port defined in the service should have an entry in it", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PortStatus"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PortStatus"}, + } +} + +func schema_k8sio_api_core_v1_LoadBalancerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancerStatus represents the status of a load-balancer.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ingress": { + SchemaProps: spec.SchemaProps{ + Description: "Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LoadBalancerIngress"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LoadBalancerIngress"}, + } +} + +func schema_k8sio_api_core_v1_LocalObjectReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_LocalVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Local represents directly-attached storage with node affinity (Beta feature)", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path of the full path to the volume on the node. It can be either a directory or block device (disk, partition, ...).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. It applies only when the Path is a block device. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default value is to auto-select a filesystem if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_NFSVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "server": { + SchemaProps: spec.SchemaProps{ + Description: "server is the hostname or IP address of the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path that is exported by the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"server", "path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Namespace(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Namespace provides a scope for Names. Use of multiple namespaces is optional.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the behavior of the Namespace. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NamespaceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status describes the current status of a Namespace. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NamespaceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NamespaceSpec", "k8s.io/api/core/v1.NamespaceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_NamespaceCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NamespaceCondition contains details about state of namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of namespace controller condition.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_NamespaceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NamespaceList is a list of Namespaces.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is the list of Namespace objects in the list. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Namespace"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Namespace", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_NamespaceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NamespaceSpec describes the attributes on a Namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "finalizers": { + SchemaProps: spec.SchemaProps{ + Description: "Finalizers is an opaque list of values that must be empty to permanently remove object from storage. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_NamespaceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NamespaceStatus is information about the current status of a Namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "Phase is the current lifecycle phase of the namespace. More info: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/\n\nPossible enum values:\n - `\"Active\"` means the namespace is available for use in the system\n - `\"Terminating\"` means the namespace is undergoing graceful termination", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Active", "Terminating"}, + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Represents the latest available observations of a namespace's current state.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NamespaceCondition"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NamespaceCondition"}, + } +} + +func schema_k8sio_api_core_v1_Node(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Node is a worker node in Kubernetes. Each node will have a unique identifier in the cache (i.e. in etcd).", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the behavior of a node. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Most recently observed status of the node. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSpec", "k8s.io/api/core/v1.NodeStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_NodeAddress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeAddress contains information for the node's address.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Node address type, one of Hostname, ExternalIP or InternalIP.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "address": { + SchemaProps: spec.SchemaProps{ + Description: "The node address.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "address"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_NodeAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Node affinity is a group of node affinity scheduling rules.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "requiredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system may or may not try to eventually evict the pod from its node.", + Ref: ref("k8s.io/api/core/v1.NodeSelector"), + }, + }, + "preferredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node matches the corresponding matchExpressions; the node(s) with the highest sum are the most preferred.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PreferredSchedulingTerm"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSelector", "k8s.io/api/core/v1.PreferredSchedulingTerm"}, + } +} + +func schema_k8sio_api_core_v1_NodeCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeCondition contains condition information for a node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of node condition.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lastHeartbeatTime": { + SchemaProps: spec.SchemaProps{ + Description: "Last time we got an update on a given condition.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "Last time the condition transit from one status to another.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) reason for the condition's last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Human readable message indicating details about last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_NodeConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeConfigSource specifies a source of node configuration. Exactly one subfield (excluding metadata) must be non-nil. This API is deprecated since 1.22", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "configMap": { + SchemaProps: spec.SchemaProps{ + Description: "ConfigMap is a reference to a Node's ConfigMap", + Ref: ref("k8s.io/api/core/v1.ConfigMapNodeConfigSource"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ConfigMapNodeConfigSource"}, + } +} + +func schema_k8sio_api_core_v1_NodeConfigStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeConfigStatus describes the status of the config assigned by Node.Spec.ConfigSource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "assigned": { + SchemaProps: spec.SchemaProps{ + Description: "Assigned reports the checkpointed config the node will try to use. When Node.Spec.ConfigSource is updated, the node checkpoints the associated config payload to local disk, along with a record indicating intended config. The node refers to this record to choose its config checkpoint, and reports this record in Assigned. Assigned only updates in the status after the record has been checkpointed to disk. When the Kubelet is restarted, it tries to make the Assigned config the Active config by loading and validating the checkpointed payload identified by Assigned.", + Ref: ref("k8s.io/api/core/v1.NodeConfigSource"), + }, + }, + "active": { + SchemaProps: spec.SchemaProps{ + Description: "Active reports the checkpointed config the node is actively using. Active will represent either the current version of the Assigned config, or the current LastKnownGood config, depending on whether attempting to use the Assigned config results in an error.", + Ref: ref("k8s.io/api/core/v1.NodeConfigSource"), + }, + }, + "lastKnownGood": { + SchemaProps: spec.SchemaProps{ + Description: "LastKnownGood reports the checkpointed config the node will fall back to when it encounters an error attempting to use the Assigned config. The Assigned config becomes the LastKnownGood config when the node determines that the Assigned config is stable and correct. This is currently implemented as a 10-minute soak period starting when the local record of Assigned config is updated. If the Assigned config is Active at the end of this period, it becomes the LastKnownGood. Note that if Spec.ConfigSource is reset to nil (use local defaults), the LastKnownGood is also immediately reset to nil, because the local default config is always assumed good. You should not make assumptions about the node's method of determining config stability and correctness, as this may change or become configurable in the future.", + Ref: ref("k8s.io/api/core/v1.NodeConfigSource"), + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Description: "Error describes any problems reconciling the Spec.ConfigSource to the Active config. Errors may occur, for example, attempting to checkpoint Spec.ConfigSource to the local Assigned record, attempting to checkpoint the payload associated with Spec.ConfigSource, attempting to load or validate the Assigned config, etc. Errors may occur at different points while syncing config. Earlier errors (e.g. download or checkpointing errors) will not result in a rollback to LastKnownGood, and may resolve across Kubelet retries. Later errors (e.g. loading or validating a checkpointed config) will result in a rollback to LastKnownGood. In the latter case, it is usually possible to resolve the error by fixing the config assigned in Spec.ConfigSource. You can find additional information for debugging by searching the error message in the Kubelet log. Error is a human-readable description of the error state; machines can check whether or not Error is empty, but should not rely on the stability of the Error text across Kubelet versions.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeConfigSource"}, + } +} + +func schema_k8sio_api_core_v1_NodeDaemonEndpoints(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeDaemonEndpoints lists ports opened by daemons running on the Node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kubeletEndpoint": { + SchemaProps: spec.SchemaProps{ + Description: "Endpoint on which Kubelet is listening.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.DaemonEndpoint"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.DaemonEndpoint"}, + } +} + +func schema_k8sio_api_core_v1_NodeList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeList is the whole list of all Nodes which have been registered with master.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of nodes", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Node"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Node", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_NodeProxyOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeProxyOptions is the query options to a Node's proxy call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Path is the URL path to use for the current proxy request to node.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_NodeResources(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeResources is an object for conveying resource information about a node. see https://kubernetes.io/docs/concepts/architecture/nodes/#capacity for more details.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Capacity": { + SchemaProps: spec.SchemaProps{ + Description: "Capacity represents the available resources of a node", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + }, + Required: []string{"Capacity"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_NodeSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A node selector represents the union of the results of one or more label queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeSelectorTerms": { + SchemaProps: spec.SchemaProps{ + Description: "Required. A list of node selector terms. The terms are ORed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSelectorTerm"), + }, + }, + }, + }, + }, + }, + Required: []string{"nodeSelectorTerms"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSelectorTerm"}, + } +} + +func schema_k8sio_api_core_v1_NodeSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "The label key that the selector applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.\n\nPossible enum values:\n - `\"DoesNotExist\"`\n - `\"Exists\"`\n - `\"Gt\"`\n - `\"In\"`\n - `\"Lt\"`\n - `\"NotIn\"`", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"DoesNotExist", "Exists", "Gt", "In", "Lt", "NotIn"}, + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Description: "An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_NodeSelectorTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A null or empty node selector term matches no objects. The requirements of them are ANDed. The TopologySelectorTerm type implements a subset of the NodeSelectorTerm.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchExpressions": { + SchemaProps: spec.SchemaProps{ + Description: "A list of node selector requirements by node's labels.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSelectorRequirement"), + }, + }, + }, + }, + }, + "matchFields": { + SchemaProps: spec.SchemaProps{ + Description: "A list of node selector requirements by node's fields.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSelectorRequirement"), + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSelectorRequirement"}, + } +} + +func schema_k8sio_api_core_v1_NodeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeSpec describes the attributes that a node is created with.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "podCIDR": { + SchemaProps: spec.SchemaProps{ + Description: "PodCIDR represents the pod IP range assigned to the node.", + Type: []string{"string"}, + Format: "", + }, + }, + "podCIDRs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "podCIDRs represents the IP ranges assigned to the node for usage by Pods on that node. If this field is specified, the 0th entry must match the podCIDR field. It may contain at most 1 value for each of IPv4 and IPv6.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "providerID": { + SchemaProps: spec.SchemaProps{ + Description: "ID of the node assigned by the cloud provider in the format: ://", + Type: []string{"string"}, + Format: "", + }, + }, + "unschedulable": { + SchemaProps: spec.SchemaProps{ + Description: "Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration", + Type: []string{"boolean"}, + Format: "", + }, + }, + "taints": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the node's taints.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Taint"), + }, + }, + }, + }, + }, + "configSource": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: Previously used to specify the source of the node's configuration for the DynamicKubeletConfig feature. This feature is removed.", + Ref: ref("k8s.io/api/core/v1.NodeConfigSource"), + }, + }, + "externalID": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated. Not all kubelets will set this field. Remove field after 1.13. see: https://issues.k8s.io/61966", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeConfigSource", "k8s.io/api/core/v1.Taint"}, + } +} + +func schema_k8sio_api_core_v1_NodeStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeStatus is information about the current status of a node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "capacity": { + SchemaProps: spec.SchemaProps{ + Description: "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "allocatable": { + SchemaProps: spec.SchemaProps{ + Description: "Allocatable represents the resources of a node that are available for scheduling. Defaults to Capacity.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.\n\nPossible enum values:\n - `\"Pending\"` means the node has been created/added by the system, but not configured.\n - `\"Running\"` means the node has been configured and has Kubernetes components running.\n - `\"Terminated\"` means the node has been removed from the cluster.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Pending", "Running", "Terminated"}, + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/concepts/nodes/node/#condition", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeCondition"), + }, + }, + }, + }, + }, + "addresses": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/concepts/nodes/node/#addresses Note: This field is declared as mergeable, but the merge key is not sufficiently unique, which can cause data corruption when it is merged. Callers should instead use a full-replacement patch. See https://pr.k8s.io/79391 for an example. Consumers should assume that addresses can change during the lifetime of a Node. However, there are some exceptions where this may not be possible, such as Pods that inherit a Node's address in its own status or consumers of the downward API (status.hostIP).", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeAddress"), + }, + }, + }, + }, + }, + "daemonEndpoints": { + SchemaProps: spec.SchemaProps{ + Description: "Endpoints of daemons running on the Node.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeDaemonEndpoints"), + }, + }, + "nodeInfo": { + SchemaProps: spec.SchemaProps{ + Description: "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#info", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSystemInfo"), + }, + }, + "images": { + SchemaProps: spec.SchemaProps{ + Description: "List of container images on this node", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerImage"), + }, + }, + }, + }, + }, + "volumesInUse": { + SchemaProps: spec.SchemaProps{ + Description: "List of attachable volumes in use (mounted) by the node.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "volumesAttached": { + SchemaProps: spec.SchemaProps{ + Description: "List of volumes that are attached to the node.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.AttachedVolume"), + }, + }, + }, + }, + }, + "config": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the config assigned to the node via the dynamic Kubelet config feature.", + Ref: ref("k8s.io/api/core/v1.NodeConfigStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.AttachedVolume", "k8s.io/api/core/v1.ContainerImage", "k8s.io/api/core/v1.NodeAddress", "k8s.io/api/core/v1.NodeCondition", "k8s.io/api/core/v1.NodeConfigStatus", "k8s.io/api/core/v1.NodeDaemonEndpoints", "k8s.io/api/core/v1.NodeSystemInfo", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_NodeSystemInfo(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "machineID": { + SchemaProps: spec.SchemaProps{ + Description: "MachineID reported by the node. For unique machine identification in the cluster this field is preferred. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "systemUUID": { + SchemaProps: spec.SchemaProps{ + Description: "SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "bootID": { + SchemaProps: spec.SchemaProps{ + Description: "Boot ID reported by the node.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kernelVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "osImage": { + SchemaProps: spec.SchemaProps{ + Description: "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "containerRuntimeVersion": { + SchemaProps: spec.SchemaProps{ + Description: "ContainerRuntime Version reported by the node through runtime remote API (e.g. containerd://1.4.2).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kubeletVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Kubelet Version reported by the node.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kubeProxyVersion": { + SchemaProps: spec.SchemaProps{ + Description: "KubeProxy Version reported by the node.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operatingSystem": { + SchemaProps: spec.SchemaProps{ + Description: "The Operating System reported by the node", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "architecture": { + SchemaProps: spec.SchemaProps{ + Description: "The Architecture reported by the node", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"machineID", "systemUUID", "bootID", "kernelVersion", "osImage", "containerRuntimeVersion", "kubeletVersion", "kubeProxyVersion", "operatingSystem", "architecture"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ObjectFieldSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ObjectFieldSelector selects an APIVersioned field of an object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Version of the schema the FieldPath is written in terms of, defaults to \"v1\".", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldPath": { + SchemaProps: spec.SchemaProps{ + Description: "Path of the field to select in the specified API version.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"fieldPath"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ObjectReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ObjectReference contains enough information to let you inspect or modify the referred object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "API version of the referent.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Specific resourceVersion to which this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldPath": { + SchemaProps: spec.SchemaProps{ + Description: "If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: \"spec.containers{name}\" (where \"name\" refers to the name of the container that triggered the event) or if no container name is specified \"spec.containers[2]\" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PersistentVolume(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolume (PV) is a storage resource provisioned by an administrator. It is analogous to a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status represents the current information/status for the persistent volume. Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeSpec", "k8s.io/api/core/v1.PersistentVolumeStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaim(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaim is a user's request for and claim to a persistent volume", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status represents the current information/status of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "k8s.io/api/core/v1.PersistentVolumeClaimStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimCondition contains details about state of pvc", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lastProbeTime": { + SchemaProps: spec.SchemaProps{ + Description: "lastProbeTime is the time we probed the condition.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "lastTransitionTime is the time the condition transitioned from one status to another.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "reason is a unique, this should be a short, machine understandable string that gives the reason for condition's last transition. If it reports \"ResizeStarted\" that means the underlying persistent volume is being resized.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "message is the human-readable message indicating details about last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimList is a list of PersistentVolumeClaim items.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items is a list of persistent volume claims. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaim"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeClaim", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimSpec describes the common attributes of storage devices and allows a Source for provider-specific attributes", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "accessModes": { + SchemaProps: spec.SchemaProps{ + Description: "accessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "selector": { + SchemaProps: spec.SchemaProps{ + Description: "selector is a label query over volumes to consider for binding.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + "volumeName": { + SchemaProps: spec.SchemaProps{ + Description: "volumeName is the binding reference to the PersistentVolume backing this claim.", + Type: []string{"string"}, + Format: "", + }, + }, + "storageClassName": { + SchemaProps: spec.SchemaProps{ + Description: "storageClassName is the name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeMode": { + SchemaProps: spec.SchemaProps{ + Description: "volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec.\n\nPossible enum values:\n - `\"Block\"` means the volume will not be formatted with a filesystem and will remain a raw block device.\n - `\"Filesystem\"` means the volume will be or is formatted with a filesystem.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Block", "Filesystem"}, + }, + }, + "dataSource": { + SchemaProps: spec.SchemaProps{ + Description: "dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. When the AnyVolumeDataSource feature gate is enabled, dataSource contents will be copied to dataSourceRef, and dataSourceRef contents will be copied to dataSource when dataSourceRef.namespace is not specified. If the namespace is specified, then dataSourceRef will not be copied to dataSource.", + Ref: ref("k8s.io/api/core/v1.TypedLocalObjectReference"), + }, + }, + "dataSourceRef": { + SchemaProps: spec.SchemaProps{ + Description: "dataSourceRef specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the dataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, when namespace isn't specified in dataSourceRef, both fields (dataSource and dataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. When namespace is specified in dataSourceRef, dataSource isn't set to the same value and must be empty. There are three important differences between dataSource and dataSourceRef: * While dataSource only allows two specific types of objects, dataSourceRef\n allows any non-core object, as well as PersistentVolumeClaim objects.\n* While dataSource ignores disallowed values (dropping them), dataSourceRef\n preserves all values, and generates an error if a disallowed value is\n specified.\n* While dataSource only allows local objects, dataSourceRef allows objects\n in any namespaces.\n(Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. (Alpha) Using the namespace field of dataSourceRef requires the CrossNamespaceVolumeDataSource feature gate to be enabled.", + Ref: ref("k8s.io/api/core/v1.TypedObjectReference"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.TypedLocalObjectReference", "k8s.io/api/core/v1.TypedObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimStatus is the current status of a persistent volume claim.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "phase represents the current phase of PersistentVolumeClaim.\n\nPossible enum values:\n - `\"Bound\"` used for PersistentVolumeClaims that are bound\n - `\"Lost\"` used for PersistentVolumeClaims that lost their underlying PersistentVolume. The claim was bound to a PersistentVolume and this volume does not exist any longer and all data on it was lost.\n - `\"Pending\"` used for PersistentVolumeClaims that are not yet bound", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Bound", "Lost", "Pending"}, + }, + }, + "accessModes": { + SchemaProps: spec.SchemaProps{ + Description: "accessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "capacity": { + SchemaProps: spec.SchemaProps{ + Description: "capacity represents the actual resources of the underlying volume.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'ResizeStarted'.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimCondition"), + }, + }, + }, + }, + }, + "allocatedResources": { + SchemaProps: spec.SchemaProps{ + Description: "allocatedResources is the storage resource within AllocatedResources tracks the capacity allocated to a PVC. It may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "resizeStatus": { + SchemaProps: spec.SchemaProps{ + Description: "resizeStatus stores status of resize operation. ResizeStatus is not set by default but when expansion is complete resizeStatus is set to empty string by resize controller or kubelet. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.\n\nPossible enum values:\n - `\"\"` When expansion is complete, the empty string is set by resize controller or kubelet.\n - `\"ControllerExpansionFailed\"` State set when expansion has failed in resize controller with a terminal error. Transient errors such as timeout should not set this status and should leave ResizeStatus unmodified, so as resize controller can resume the volume expansion.\n - `\"ControllerExpansionInProgress\"` State set when resize controller starts expanding the volume in control-plane\n - `\"NodeExpansionFailed\"` State set when expansion has failed in kubelet with a terminal error. Transient errors don't set NodeExpansionFailed.\n - `\"NodeExpansionInProgress\"` State set when kubelet starts expanding the volume.\n - `\"NodeExpansionPending\"` State set when resize controller has finished expanding the volume but further expansion is needed on the node.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"", "ControllerExpansionFailed", "ControllerExpansionInProgress", "NodeExpansionFailed", "NodeExpansionInProgress", "NodeExpansionPending"}, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeClaimCondition", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimTemplate is used to produce PersistentVolumeClaim objects as part of an EphemeralVolumeSource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "The specification for the PersistentVolumeClaim. The entire content is copied unchanged into the PVC that gets created from this template. The same fields as in a PersistentVolumeClaim are also valid here.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimSpec"), + }, + }, + }, + Required: []string{"spec"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeClaimVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace. This volume finds the bound PV and mounts that volume for the pod. A PersistentVolumeClaimVolumeSource is, essentially, a wrapper around another type of volume that is owned by someone else (the system).", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "claimName": { + SchemaProps: spec.SchemaProps{ + Description: "claimName is the name of a PersistentVolumeClaim in the same namespace as the pod using this volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly Will force the ReadOnly setting in VolumeMounts. Default false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"claimName"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeList is a list of PersistentVolume items.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items is a list of persistent volumes. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PersistentVolume"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PersistentVolume", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeSource is similar to VolumeSource but meant for the administrator who creates PVs. Exactly one of its members must be set.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "gcePersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Ref: ref("k8s.io/api/core/v1.GCEPersistentDiskVolumeSource"), + }, + }, + "awsElasticBlockStore": { + SchemaProps: spec.SchemaProps{ + Description: "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Ref: ref("k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource"), + }, + }, + "hostPath": { + SchemaProps: spec.SchemaProps{ + Description: "hostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + Ref: ref("k8s.io/api/core/v1.HostPathVolumeSource"), + }, + }, + "glusterfs": { + SchemaProps: spec.SchemaProps{ + Description: "glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://examples.k8s.io/volumes/glusterfs/README.md", + Ref: ref("k8s.io/api/core/v1.GlusterfsPersistentVolumeSource"), + }, + }, + "nfs": { + SchemaProps: spec.SchemaProps{ + Description: "nfs represents an NFS mount on the host. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Ref: ref("k8s.io/api/core/v1.NFSVolumeSource"), + }, + }, + "rbd": { + SchemaProps: spec.SchemaProps{ + Description: "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md", + Ref: ref("k8s.io/api/core/v1.RBDPersistentVolumeSource"), + }, + }, + "iscsi": { + SchemaProps: spec.SchemaProps{ + Description: "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin.", + Ref: ref("k8s.io/api/core/v1.ISCSIPersistentVolumeSource"), + }, + }, + "cinder": { + SchemaProps: spec.SchemaProps{ + Description: "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Ref: ref("k8s.io/api/core/v1.CinderPersistentVolumeSource"), + }, + }, + "cephfs": { + SchemaProps: spec.SchemaProps{ + Description: "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.CephFSPersistentVolumeSource"), + }, + }, + "fc": { + SchemaProps: spec.SchemaProps{ + Description: "fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + Ref: ref("k8s.io/api/core/v1.FCVolumeSource"), + }, + }, + "flocker": { + SchemaProps: spec.SchemaProps{ + Description: "flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running", + Ref: ref("k8s.io/api/core/v1.FlockerVolumeSource"), + }, + }, + "flexVolume": { + SchemaProps: spec.SchemaProps{ + Description: "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.", + Ref: ref("k8s.io/api/core/v1.FlexPersistentVolumeSource"), + }, + }, + "azureFile": { + SchemaProps: spec.SchemaProps{ + Description: "azureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureFilePersistentVolumeSource"), + }, + }, + "vsphereVolume": { + SchemaProps: spec.SchemaProps{ + Description: "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"), + }, + }, + "quobyte": { + SchemaProps: spec.SchemaProps{ + Description: "quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.QuobyteVolumeSource"), + }, + }, + "azureDisk": { + SchemaProps: spec.SchemaProps{ + Description: "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureDiskVolumeSource"), + }, + }, + "photonPersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource"), + }, + }, + "portworxVolume": { + SchemaProps: spec.SchemaProps{ + Description: "portworxVolume represents a portworx volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PortworxVolumeSource"), + }, + }, + "scaleIO": { + SchemaProps: spec.SchemaProps{ + Description: "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.ScaleIOPersistentVolumeSource"), + }, + }, + "local": { + SchemaProps: spec.SchemaProps{ + Description: "local represents directly-attached storage with node affinity", + Ref: ref("k8s.io/api/core/v1.LocalVolumeSource"), + }, + }, + "storageos": { + SchemaProps: spec.SchemaProps{ + Description: "storageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://examples.k8s.io/volumes/storageos/README.md", + Ref: ref("k8s.io/api/core/v1.StorageOSPersistentVolumeSource"), + }, + }, + "csi": { + SchemaProps: spec.SchemaProps{ + Description: "csi represents storage that is handled by an external CSI driver (Beta feature).", + Ref: ref("k8s.io/api/core/v1.CSIPersistentVolumeSource"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource", "k8s.io/api/core/v1.AzureDiskVolumeSource", "k8s.io/api/core/v1.AzureFilePersistentVolumeSource", "k8s.io/api/core/v1.CSIPersistentVolumeSource", "k8s.io/api/core/v1.CephFSPersistentVolumeSource", "k8s.io/api/core/v1.CinderPersistentVolumeSource", "k8s.io/api/core/v1.FCVolumeSource", "k8s.io/api/core/v1.FlexPersistentVolumeSource", "k8s.io/api/core/v1.FlockerVolumeSource", "k8s.io/api/core/v1.GCEPersistentDiskVolumeSource", "k8s.io/api/core/v1.GlusterfsPersistentVolumeSource", "k8s.io/api/core/v1.HostPathVolumeSource", "k8s.io/api/core/v1.ISCSIPersistentVolumeSource", "k8s.io/api/core/v1.LocalVolumeSource", "k8s.io/api/core/v1.NFSVolumeSource", "k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource", "k8s.io/api/core/v1.PortworxVolumeSource", "k8s.io/api/core/v1.QuobyteVolumeSource", "k8s.io/api/core/v1.RBDPersistentVolumeSource", "k8s.io/api/core/v1.ScaleIOPersistentVolumeSource", "k8s.io/api/core/v1.StorageOSPersistentVolumeSource", "k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeSpec is the specification of a persistent volume.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "capacity": { + SchemaProps: spec.SchemaProps{ + Description: "capacity is the description of the persistent volume's resources and capacity. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "gcePersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Ref: ref("k8s.io/api/core/v1.GCEPersistentDiskVolumeSource"), + }, + }, + "awsElasticBlockStore": { + SchemaProps: spec.SchemaProps{ + Description: "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Ref: ref("k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource"), + }, + }, + "hostPath": { + SchemaProps: spec.SchemaProps{ + Description: "hostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + Ref: ref("k8s.io/api/core/v1.HostPathVolumeSource"), + }, + }, + "glusterfs": { + SchemaProps: spec.SchemaProps{ + Description: "glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://examples.k8s.io/volumes/glusterfs/README.md", + Ref: ref("k8s.io/api/core/v1.GlusterfsPersistentVolumeSource"), + }, + }, + "nfs": { + SchemaProps: spec.SchemaProps{ + Description: "nfs represents an NFS mount on the host. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Ref: ref("k8s.io/api/core/v1.NFSVolumeSource"), + }, + }, + "rbd": { + SchemaProps: spec.SchemaProps{ + Description: "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md", + Ref: ref("k8s.io/api/core/v1.RBDPersistentVolumeSource"), + }, + }, + "iscsi": { + SchemaProps: spec.SchemaProps{ + Description: "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin.", + Ref: ref("k8s.io/api/core/v1.ISCSIPersistentVolumeSource"), + }, + }, + "cinder": { + SchemaProps: spec.SchemaProps{ + Description: "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Ref: ref("k8s.io/api/core/v1.CinderPersistentVolumeSource"), + }, + }, + "cephfs": { + SchemaProps: spec.SchemaProps{ + Description: "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.CephFSPersistentVolumeSource"), + }, + }, + "fc": { + SchemaProps: spec.SchemaProps{ + Description: "fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + Ref: ref("k8s.io/api/core/v1.FCVolumeSource"), + }, + }, + "flocker": { + SchemaProps: spec.SchemaProps{ + Description: "flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running", + Ref: ref("k8s.io/api/core/v1.FlockerVolumeSource"), + }, + }, + "flexVolume": { + SchemaProps: spec.SchemaProps{ + Description: "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.", + Ref: ref("k8s.io/api/core/v1.FlexPersistentVolumeSource"), + }, + }, + "azureFile": { + SchemaProps: spec.SchemaProps{ + Description: "azureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureFilePersistentVolumeSource"), + }, + }, + "vsphereVolume": { + SchemaProps: spec.SchemaProps{ + Description: "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"), + }, + }, + "quobyte": { + SchemaProps: spec.SchemaProps{ + Description: "quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.QuobyteVolumeSource"), + }, + }, + "azureDisk": { + SchemaProps: spec.SchemaProps{ + Description: "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureDiskVolumeSource"), + }, + }, + "photonPersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource"), + }, + }, + "portworxVolume": { + SchemaProps: spec.SchemaProps{ + Description: "portworxVolume represents a portworx volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PortworxVolumeSource"), + }, + }, + "scaleIO": { + SchemaProps: spec.SchemaProps{ + Description: "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.ScaleIOPersistentVolumeSource"), + }, + }, + "local": { + SchemaProps: spec.SchemaProps{ + Description: "local represents directly-attached storage with node affinity", + Ref: ref("k8s.io/api/core/v1.LocalVolumeSource"), + }, + }, + "storageos": { + SchemaProps: spec.SchemaProps{ + Description: "storageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://examples.k8s.io/volumes/storageos/README.md", + Ref: ref("k8s.io/api/core/v1.StorageOSPersistentVolumeSource"), + }, + }, + "csi": { + SchemaProps: spec.SchemaProps{ + Description: "csi represents storage that is handled by an external CSI driver (Beta feature).", + Ref: ref("k8s.io/api/core/v1.CSIPersistentVolumeSource"), + }, + }, + "accessModes": { + SchemaProps: spec.SchemaProps{ + Description: "accessModes contains all ways the volume can be mounted. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "claimRef": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "granular", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "claimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim.VolumeName is the authoritative bind between PV and PVC. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#binding", + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + "persistentVolumeReclaimPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "persistentVolumeReclaimPolicy defines what happens to a persistent volume when released from its claim. Valid options are Retain (default for manually created PersistentVolumes), Delete (default for dynamically provisioned PersistentVolumes), and Recycle (deprecated). Recycle must be supported by the volume plugin underlying this PersistentVolume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming\n\nPossible enum values:\n - `\"Delete\"` means the volume will be deleted from Kubernetes on release from its claim. The volume plugin must support Deletion.\n - `\"Recycle\"` means the volume will be recycled back into the pool of unbound persistent volumes on release from its claim. The volume plugin must support Recycling.\n - `\"Retain\"` means the volume will be left in its current phase (Released) for manual reclamation by the administrator. The default policy is Retain.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Delete", "Recycle", "Retain"}, + }, + }, + "storageClassName": { + SchemaProps: spec.SchemaProps{ + Description: "storageClassName is the name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.", + Type: []string{"string"}, + Format: "", + }, + }, + "mountOptions": { + SchemaProps: spec.SchemaProps{ + Description: "mountOptions is the list of mount options, e.g. [\"ro\", \"soft\"]. Not validated - mount will simply fail if one is invalid. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "volumeMode": { + SchemaProps: spec.SchemaProps{ + Description: "volumeMode defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state. Value of Filesystem is implied when not included in spec.\n\nPossible enum values:\n - `\"Block\"` means the volume will not be formatted with a filesystem and will remain a raw block device.\n - `\"Filesystem\"` means the volume will be or is formatted with a filesystem.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Block", "Filesystem"}, + }, + }, + "nodeAffinity": { + SchemaProps: spec.SchemaProps{ + Description: "nodeAffinity defines constraints that limit what nodes this volume can be accessed from. This field influences the scheduling of pods that use this volume.", + Ref: ref("k8s.io/api/core/v1.VolumeNodeAffinity"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource", "k8s.io/api/core/v1.AzureDiskVolumeSource", "k8s.io/api/core/v1.AzureFilePersistentVolumeSource", "k8s.io/api/core/v1.CSIPersistentVolumeSource", "k8s.io/api/core/v1.CephFSPersistentVolumeSource", "k8s.io/api/core/v1.CinderPersistentVolumeSource", "k8s.io/api/core/v1.FCVolumeSource", "k8s.io/api/core/v1.FlexPersistentVolumeSource", "k8s.io/api/core/v1.FlockerVolumeSource", "k8s.io/api/core/v1.GCEPersistentDiskVolumeSource", "k8s.io/api/core/v1.GlusterfsPersistentVolumeSource", "k8s.io/api/core/v1.HostPathVolumeSource", "k8s.io/api/core/v1.ISCSIPersistentVolumeSource", "k8s.io/api/core/v1.LocalVolumeSource", "k8s.io/api/core/v1.NFSVolumeSource", "k8s.io/api/core/v1.ObjectReference", "k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource", "k8s.io/api/core/v1.PortworxVolumeSource", "k8s.io/api/core/v1.QuobyteVolumeSource", "k8s.io/api/core/v1.RBDPersistentVolumeSource", "k8s.io/api/core/v1.ScaleIOPersistentVolumeSource", "k8s.io/api/core/v1.StorageOSPersistentVolumeSource", "k8s.io/api/core/v1.VolumeNodeAffinity", "k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_PersistentVolumeStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PersistentVolumeStatus is the current status of a persistent volume.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase\n\nPossible enum values:\n - `\"Available\"` used for PersistentVolumes that are not yet bound Available volumes are held by the binder and matched to PersistentVolumeClaims\n - `\"Bound\"` used for PersistentVolumes that are bound\n - `\"Failed\"` used for PersistentVolumes that failed to be correctly recycled or deleted after being released from a claim\n - `\"Pending\"` used for PersistentVolumes that are not available\n - `\"Released\"` used for PersistentVolumes where the bound PersistentVolumeClaim was deleted released volumes must be recycled before becoming available again this phase is used by the persistent volume claim binder to signal to another process to reclaim the resource", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Available", "Bound", "Failed", "Pending", "Released"}, + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "message is a human-readable message indicating details about why the volume is in this state.", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PhotonPersistentDiskVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Photon Controller persistent disk resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pdID": { + SchemaProps: spec.SchemaProps{ + Description: "pdID is the ID that identifies Photon Controller persistent disk", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"pdID"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Pod(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodSpec", "k8s.io/api/core/v1.PodStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PodAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Pod affinity is a group of inter pod affinity scheduling rules.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "requiredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodAffinityTerm"), + }, + }, + }, + }, + }, + "preferredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.WeightedPodAffinityTerm"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodAffinityTerm", "k8s.io/api/core/v1.WeightedPodAffinityTerm"}, + } +} + +func schema_k8sio_api_core_v1_PodAffinityTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key matches that of any node on which a pod of the set of pods is running", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A label query over a set of resources, in this case pods.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "namespaces": { + SchemaProps: spec.SchemaProps{ + Description: "namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means \"this pod's namespace\".", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "topologyKey": { + SchemaProps: spec.SchemaProps{ + Description: "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "namespaceSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means \"this pod's namespace\". An empty selector ({}) matches all namespaces.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + }, + Required: []string{"topologyKey"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_k8sio_api_core_v1_PodAntiAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Pod anti affinity is a group of inter pod anti affinity scheduling rules.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "requiredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodAffinityTerm"), + }, + }, + }, + }, + }, + "preferredDuringSchedulingIgnoredDuringExecution": { + SchemaProps: spec.SchemaProps{ + Description: "The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.WeightedPodAffinityTerm"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodAffinityTerm", "k8s.io/api/core/v1.WeightedPodAffinityTerm"}, + } +} + +func schema_k8sio_api_core_v1_PodAttachOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodAttachOptions is the query options to a Pod's remote attach call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "stdin": { + SchemaProps: spec.SchemaProps{ + Description: "Stdin if true, redirects the standard input stream of the pod for this call. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stdout": { + SchemaProps: spec.SchemaProps{ + Description: "Stdout if true indicates that stdout is to be redirected for the attach call. Defaults to true.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stderr": { + SchemaProps: spec.SchemaProps{ + Description: "Stderr if true indicates that stderr is to be redirected for the attach call. Defaults to true.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tty": { + SchemaProps: spec.SchemaProps{ + Description: "TTY if true indicates that a tty will be allocated for the attach call. This is passed through the container runtime so the tty is allocated on the worker node by the container runtime. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "container": { + SchemaProps: spec.SchemaProps{ + Description: "The container in which to execute the command. Defaults to only container if there is only one container in the pod.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodCondition contains details for the current condition of this pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type is the type of the condition. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lastProbeTime": { + SchemaProps: spec.SchemaProps{ + Description: "Last time we probed the condition.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "Last time the condition transitioned from one status to another.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "Unique, one-word, CamelCase reason for the condition's last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Human-readable message indicating details about last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_PodDNSConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nameservers": { + SchemaProps: spec.SchemaProps{ + Description: "A list of DNS name server IP addresses. This will be appended to the base nameservers generated from DNSPolicy. Duplicated nameservers will be removed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "searches": { + SchemaProps: spec.SchemaProps{ + Description: "A list of DNS search domains for host-name lookup. This will be appended to the base search paths generated from DNSPolicy. Duplicated search paths will be removed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "A list of DNS resolver options. This will be merged with the base options generated from DNSPolicy. Duplicated entries will be removed. Resolution options given in Options will override those that appear in the base DNSPolicy.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodDNSConfigOption"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodDNSConfigOption"}, + } +} + +func schema_k8sio_api_core_v1_PodDNSConfigOption(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodDNSConfigOption defines DNS resolver options of a pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Required.", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodExecOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodExecOptions is the query options to a Pod's remote exec call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "stdin": { + SchemaProps: spec.SchemaProps{ + Description: "Redirect the standard input stream of the pod for this call. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stdout": { + SchemaProps: spec.SchemaProps{ + Description: "Redirect the standard output stream of the pod for this call.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "stderr": { + SchemaProps: spec.SchemaProps{ + Description: "Redirect the standard error stream of the pod for this call.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tty": { + SchemaProps: spec.SchemaProps{ + Description: "TTY if true indicates that a tty will be allocated for the exec call. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "container": { + SchemaProps: spec.SchemaProps{ + Description: "Container in which to execute the command. Defaults to only container if there is only one container in the pod.", + Type: []string{"string"}, + Format: "", + }, + }, + "command": { + SchemaProps: spec.SchemaProps{ + Description: "Command is the remote command to execute. argv array. Not executed within a shell.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"command"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodIP(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "IP address information for entries in the (plural) PodIPs field. Each entry includes:\n\n\tIP: An IP address allocated to the pod. Routable at least within the cluster.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ip": { + SchemaProps: spec.SchemaProps{ + Description: "ip is an IP address (IPv4 or IPv6) assigned to the pod", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodList is a list of Pods.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of pods. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Pod"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Pod", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_PodLogOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodLogOptions is the query options for a Pod's logs REST call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "container": { + SchemaProps: spec.SchemaProps{ + Description: "The container for which to stream logs. Defaults to only container if there is one container in the pod.", + Type: []string{"string"}, + Format: "", + }, + }, + "follow": { + SchemaProps: spec.SchemaProps{ + Description: "Follow the log stream of the pod. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "previous": { + SchemaProps: spec.SchemaProps{ + Description: "Return previous terminated container logs. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "sinceSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "A relative time in seconds before the current time from which to show logs. If this value precedes the time a pod was started, only logs since the pod start will be returned. If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "sinceTime": { + SchemaProps: spec.SchemaProps{ + Description: "An RFC3339 timestamp from which to show logs. If this value precedes the time a pod was started, only logs since the pod start will be returned. If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "timestamps": { + SchemaProps: spec.SchemaProps{ + Description: "If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every line of log output. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "tailLines": { + SchemaProps: spec.SchemaProps{ + Description: "If set, the number of lines from the end of the logs to show. If not specified, logs are shown from the creation of the container or sinceSeconds or sinceTime", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "limitBytes": { + SchemaProps: spec.SchemaProps{ + Description: "If set, the number of bytes to read from the server before terminating the log output. This may not display a complete final line of logging, and may return slightly more or slightly less than the specified limit.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "insecureSkipTLSVerifyBackend": { + SchemaProps: spec.SchemaProps{ + Description: "insecureSkipTLSVerifyBackend indicates that the apiserver should not confirm the validity of the serving certificate of the backend it is connecting to. This will make the HTTPS connection between the apiserver and the backend insecure. This means the apiserver cannot verify the log data it is receiving came from the real kubelet. If the kubelet is configured to verify the apiserver's TLS credentials, it does not mean the connection to the real kubelet is vulnerable to a man in the middle attack (e.g. an attacker could not intercept the actual log data coming from the real kubelet).", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_PodOS(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodOS defines the OS parameters of a pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of the operating system. The currently supported values are linux and windows. Additional value may be defined in future and can be one of: https://github.com/opencontainers/runtime-spec/blob/master/config.md#platform-specific-configuration Clients should expect to handle additional values and treat unrecognized values in this field as os: null", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodPortForwardOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodPortForwardOptions is the query options to a Pod's port forward call when using WebSockets. The `port` query parameter must specify the port or ports (comma separated) to forward over. Port forwarding over SPDY does not use these options. It requires the port to be passed in the `port` header as part of request.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "ports": { + SchemaProps: spec.SchemaProps{ + Description: "List of ports to forward Required when using WebSockets", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodProxyOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodProxyOptions is the query options to a Pod's proxy call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Path is the URL path to use for the current proxy request to pod.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodReadinessGate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodReadinessGate contains the reference to a pod condition", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "conditionType": { + SchemaProps: spec.SchemaProps{ + Description: "ConditionType refers to a condition in the pod's condition list with matching type.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"conditionType"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodResourceClaim(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodResourceClaim references exactly one ResourceClaim through a ClaimSource. It adds a name to it that uniquely identifies the ResourceClaim inside the Pod. Containers that need access to the ResourceClaim reference it with this name.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name uniquely identifies this resource claim inside the pod. This must be a DNS_LABEL.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "source": { + SchemaProps: spec.SchemaProps{ + Description: "Source describes where to find the ResourceClaim.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ClaimSource"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ClaimSource"}, + } +} + +func schema_k8sio_api_core_v1_PodSchedulingGate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodSchedulingGate is associated to a Pod to guard its scheduling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the scheduling gate. Each scheduling gate must have a unique name field.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PodSecurityContext(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "seLinuxOptions": { + SchemaProps: spec.SchemaProps{ + Description: "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows.", + Ref: ref("k8s.io/api/core/v1.SELinuxOptions"), + }, + }, + "windowsOptions": { + SchemaProps: spec.SchemaProps{ + Description: "The Windows specific settings applied to all containers. If unspecified, the options within a container's SecurityContext will be used. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is linux.", + Ref: ref("k8s.io/api/core/v1.WindowsSecurityContextOptions"), + }, + }, + "runAsUser": { + SchemaProps: spec.SchemaProps{ + Description: "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "runAsGroup": { + SchemaProps: spec.SchemaProps{ + Description: "The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "runAsNonRoot": { + SchemaProps: spec.SchemaProps{ + Description: "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "supplementalGroups": { + SchemaProps: spec.SchemaProps{ + Description: "A list of groups applied to the first process run in each container, in addition to the container's primary GID, the fsGroup (if specified), and group memberships defined in the container image for the uid of the container process. If unspecified, no additional groups are added to any container. Note that group memberships defined in the container image for the uid of the container process are still effective, even if they are not included in this list. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + "fsGroup": { + SchemaProps: spec.SchemaProps{ + Description: "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw----\n\nIf unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "sysctls": { + SchemaProps: spec.SchemaProps{ + Description: "Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported sysctls (by the container runtime) might fail to launch. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Sysctl"), + }, + }, + }, + }, + }, + "fsGroupChangePolicy": { + SchemaProps: spec.SchemaProps{ + Description: "fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod. This field will only apply to volume types which support fsGroup based ownership(and permissions). It will have no effect on ephemeral volume types such as: secret, configmaps and emptydir. Valid values are \"OnRootMismatch\" and \"Always\". If not specified, \"Always\" is used. Note that this field cannot be set when spec.os.name is windows.\n\nPossible enum values:\n - `\"Always\"` indicates that volume's ownership and permissions should always be changed whenever volume is mounted inside a Pod. This the default behavior.\n - `\"OnRootMismatch\"` indicates that volume's ownership and permissions will be changed only when permission and ownership of root directory does not match with expected permissions on the volume. This can help shorten the time it takes to change ownership and permissions of a volume.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Always", "OnRootMismatch"}, + }, + }, + "seccompProfile": { + SchemaProps: spec.SchemaProps{ + Description: "The seccomp options to use by the containers in this pod. Note that this field cannot be set when spec.os.name is windows.", + Ref: ref("k8s.io/api/core/v1.SeccompProfile"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SELinuxOptions", "k8s.io/api/core/v1.SeccompProfile", "k8s.io/api/core/v1.Sysctl", "k8s.io/api/core/v1.WindowsSecurityContextOptions"}, + } +} + +func schema_k8sio_api_core_v1_PodSignature(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Describes the class of pods that should avoid this node. Exactly one field should be set.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "podController": { + SchemaProps: spec.SchemaProps{ + Description: "Reference to controller whose pods should avoid this node.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference"}, + } +} + +func schema_k8sio_api_core_v1_PodSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodSpec is a description of a pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumes": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Volume"), + }, + }, + }, + }, + }, + "initContainers": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Container"), + }, + }, + }, + }, + }, + "containers": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Container"), + }, + }, + }, + }, + }, + "ephemeralContainers": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.EphemeralContainer"), + }, + }, + }, + }, + }, + "restartPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Restart policy for all containers within the pod. One of Always, OnFailure, Never. In some contexts, only a subset of those values may be permitted. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy\n\nPossible enum values:\n - `\"Always\"`\n - `\"Never\"`\n - `\"OnFailure\"`", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Always", "Never", "OnFailure"}, + }, + }, + "terminationGracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "activeDeadlineSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "dnsPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.\n\nPossible enum values:\n - `\"ClusterFirst\"` indicates that the pod should use cluster DNS first unless hostNetwork is true, if it is available, then fall back on the default (as determined by kubelet) DNS settings.\n - `\"ClusterFirstWithHostNet\"` indicates that the pod should use cluster DNS first, if it is available, then fall back on the default (as determined by kubelet) DNS settings.\n - `\"Default\"` indicates that the pod should use the default (as determined by kubelet) DNS settings.\n - `\"None\"` indicates that the pod should use empty DNS settings. DNS parameters such as nameservers and search paths should be defined via DNSConfig.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"ClusterFirst", "ClusterFirstWithHostNet", "Default", "None"}, + }, + }, + "nodeSelector": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "serviceAccountName": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + Type: []string{"string"}, + Format: "", + }, + }, + "serviceAccount": { + SchemaProps: spec.SchemaProps{ + Description: "DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.", + Type: []string{"string"}, + Format: "", + }, + }, + "automountServiceAccountToken": { + SchemaProps: spec.SchemaProps{ + Description: "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "nodeName": { + SchemaProps: spec.SchemaProps{ + Description: "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.", + Type: []string{"string"}, + Format: "", + }, + }, + "hostNetwork": { + SchemaProps: spec.SchemaProps{ + Description: "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "hostPID": { + SchemaProps: spec.SchemaProps{ + Description: "Use the host's pid namespace. Optional: Default to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "hostIPC": { + SchemaProps: spec.SchemaProps{ + Description: "Use the host's ipc namespace. Optional: Default to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "shareProcessNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set. Optional: Default to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + Ref: ref("k8s.io/api/core/v1.PodSecurityContext"), + }, + }, + "imagePullSecrets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + "hostname": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", + Type: []string{"string"}, + Format: "", + }, + }, + "subdomain": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the fully qualified Pod hostname will be \"...svc.\". If not specified, the pod will not have a domainname at all.", + Type: []string{"string"}, + Format: "", + }, + }, + "affinity": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's scheduling constraints", + Ref: ref("k8s.io/api/core/v1.Affinity"), + }, + }, + "schedulerName": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.", + Type: []string{"string"}, + Format: "", + }, + }, + "tolerations": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's tolerations.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "hostAliases": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "ip", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.HostAlias"), + }, + }, + }, + }, + }, + "priorityClassName": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, indicates the pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.", + Type: []string{"string"}, + Format: "", + }, + }, + "priority": { + SchemaProps: spec.SchemaProps{ + Description: "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "dnsConfig": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.", + Ref: ref("k8s.io/api/core/v1.PodDNSConfig"), + }, + }, + "readinessGates": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to \"True\" More info: https://git.k8s.io/enhancements/keps/sig-network/580-pod-readiness-gates", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodReadinessGate"), + }, + }, + }, + }, + }, + "runtimeClassName": { + SchemaProps: spec.SchemaProps{ + Description: "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class", + Type: []string{"string"}, + Format: "", + }, + }, + "enableServiceLinks": { + SchemaProps: spec.SchemaProps{ + Description: "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links. Optional: Defaults to true.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "preemptionPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.\n\nPossible enum values:\n - `\"Never\"` means that pod never preempts other pods with lower priority.\n - `\"PreemptLowerPriority\"` means that pod can preempt other pods with lower priority.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Never", "PreemptLowerPriority"}, + }, + }, + "overhead": { + SchemaProps: spec.SchemaProps{ + Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "topologySpreadConstraints": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "topologyKey", + "whenUnsatisfiable", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "topologyKey", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.TopologySpreadConstraint"), + }, + }, + }, + }, + }, + "setHostnameAsFQDN": { + SchemaProps: spec.SchemaProps{ + Description: "If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default). In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname). In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN. If a pod does not have FQDN, this has no effect. Default to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "os": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the OS of the containers in the pod. Some pod and container fields are restricted if this is set.\n\nIf the OS field is set to linux, the following fields must be unset: -securityContext.windowsOptions\n\nIf the OS field is set to windows, following fields must be unset: - spec.hostPID - spec.hostIPC - spec.hostUsers - spec.securityContext.seLinuxOptions - spec.securityContext.seccompProfile - spec.securityContext.fsGroup - spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls - spec.shareProcessNamespace - spec.securityContext.runAsUser - spec.securityContext.runAsGroup - spec.securityContext.supplementalGroups - spec.containers[*].securityContext.seLinuxOptions - spec.containers[*].securityContext.seccompProfile - spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem - spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation - spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser - spec.containers[*].securityContext.runAsGroup", + Ref: ref("k8s.io/api/core/v1.PodOS"), + }, + }, + "hostUsers": { + SchemaProps: spec.SchemaProps{ + Description: "Use the host's user namespace. Optional: Default to true. If set to true or not present, the pod will be run in the host user namespace, useful for when the pod needs a feature only available to the host user namespace, such as loading a kernel module with CAP_SYS_MODULE. When set to false, a new userns is created for the pod. Setting false is useful for mitigating container breakout vulnerabilities even allowing users to run their containers as root without actually having root privileges on the host. This field is alpha-level and is only honored by servers that enable the UserNamespacesSupport feature.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "schedulingGates": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "name", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "SchedulingGates is an opaque list of values that if specified will block scheduling the pod. If schedulingGates is not empty, the pod will stay in the SchedulingGated state and the scheduler will not attempt to schedule the pod.\n\nSchedulingGates can only be set at pod creation time, and be removed only afterwards.\n\nThis is a beta feature enabled by the PodSchedulingReadiness feature gate.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodSchedulingGate"), + }, + }, + }, + }, + }, + "resourceClaims": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "name", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ResourceClaims defines which ResourceClaims must be allocated and reserved before the Pod is allowed to start. The resources will be made available to those containers which consume them by name.\n\nThis is an alpha field and requires enabling the DynamicResourceAllocation feature gate.\n\nThis field is immutable.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodResourceClaim"), + }, + }, + }, + }, + }, + }, + Required: []string{"containers"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.EphemeralContainer", "k8s.io/api/core/v1.HostAlias", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.PodOS", "k8s.io/api/core/v1.PodReadinessGate", "k8s.io/api/core/v1.PodResourceClaim", "k8s.io/api/core/v1.PodSchedulingGate", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.TopologySpreadConstraint", "k8s.io/api/core/v1.Volume", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_PodStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodStatus represents information about the status of a pod. Status may trail the actual state of a system, especially if the node that hosts the pod cannot contact the control plane.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "The phase of a Pod is a simple, high-level summary of where the Pod is in its lifecycle. The conditions array, the reason and message fields, and the individual container status arrays contain more detail about the pod's status. There are five possible phase values:\n\nPending: The pod has been accepted by the Kubernetes system, but one or more of the container images has not been created. This includes time before being scheduled as well as time spent downloading images over the network, which could take a while. Running: The pod has been bound to a node, and all of the containers have been created. At least one container is still running, or is in the process of starting or restarting. Succeeded: All containers in the pod have terminated in success, and will not be restarted. Failed: All containers in the pod have terminated, and at least one container has terminated in failure. The container either exited with non-zero status or was terminated by the system. Unknown: For some reason the state of the pod could not be obtained, typically due to an error in communicating with the host of the pod.\n\nMore info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase\n\nPossible enum values:\n - `\"Failed\"` means that all containers in the pod have terminated, and at least one container has terminated in a failure (exited with a non-zero exit code or was stopped by the system).\n - `\"Pending\"` means the pod has been accepted by the system, but one or more of the containers has not been started. This includes time before being bound to a node, as well as time spent pulling images onto the host.\n - `\"Running\"` means the pod has been bound to a node and all of the containers have been started. At least one container is still running or is in the process of being restarted.\n - `\"Succeeded\"` means that all containers in the pod have voluntarily terminated with a container exit code of 0, and the system is not going to restart any of these containers.\n - `\"Unknown\"` means that for some reason the state of the pod could not be obtained, typically due to an error in communicating with the host of the pod. Deprecated: It isn't being set since 2015 (74da3b14b0c0f658b3bb8d2def5094686d0e9095)", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Failed", "Pending", "Running", "Succeeded", "Unknown"}, + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Current service state of pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodCondition"), + }, + }, + }, + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human readable message indicating details about why the pod is in this condition.", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "A brief CamelCase message indicating details about why the pod is in this state. e.g. 'Evicted'", + Type: []string{"string"}, + Format: "", + }, + }, + "nominatedNodeName": { + SchemaProps: spec.SchemaProps{ + Description: "nominatedNodeName is set only when this pod preempts other pods on the node, but it cannot be scheduled right away as preemption victims receive their graceful termination periods. This field does not guarantee that the pod will be scheduled on this node. Scheduler may decide to place the pod elsewhere if other nodes become available sooner. Scheduler may also decide to give the resources on this node to a higher priority pod that is created after preemption. As a result, this field may be different than PodSpec.nodeName when the pod is scheduled.", + Type: []string{"string"}, + Format: "", + }, + }, + "hostIP": { + SchemaProps: spec.SchemaProps{ + Description: "IP address of the host to which the pod is assigned. Empty if not yet scheduled.", + Type: []string{"string"}, + Format: "", + }, + }, + "podIP": { + SchemaProps: spec.SchemaProps{ + Description: "IP address allocated to the pod. Routable at least within the cluster. Empty if not yet allocated.", + Type: []string{"string"}, + Format: "", + }, + }, + "podIPs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "ip", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "podIPs holds the IP addresses allocated to the pod. If this field is specified, the 0th entry must match the podIP field. Pods may be allocated at most 1 value for each of IPv4 and IPv6. This list is empty if no IPs have been allocated yet.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodIP"), + }, + }, + }, + }, + }, + "startTime": { + SchemaProps: spec.SchemaProps{ + Description: "RFC 3339 date and time at which the object was acknowledged by the Kubelet. This is before the Kubelet pulled the container image(s) for the pod.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "initContainerStatuses": { + SchemaProps: spec.SchemaProps{ + Description: "The list has one entry per init container in the manifest. The most recent successful init container will have ready = true, the most recently started container will have startTime set. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerStatus"), + }, + }, + }, + }, + }, + "containerStatuses": { + SchemaProps: spec.SchemaProps{ + Description: "The list has one entry per container in the manifest. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerStatus"), + }, + }, + }, + }, + }, + "qosClass": { + SchemaProps: spec.SchemaProps{ + Description: "The Quality of Service (QOS) classification assigned to the pod based on resource requirements See PodQOSClass type for available QOS classes More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#quality-of-service-classes\n\nPossible enum values:\n - `\"BestEffort\"` is the BestEffort qos class.\n - `\"Burstable\"` is the Burstable qos class.\n - `\"Guaranteed\"` is the Guaranteed qos class.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"BestEffort", "Burstable", "Guaranteed"}, + }, + }, + "ephemeralContainerStatuses": { + SchemaProps: spec.SchemaProps{ + Description: "Status for any ephemeral containers that have run in this pod.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ContainerStatus"), + }, + }, + }, + }, + }, + "resize": { + SchemaProps: spec.SchemaProps{ + Description: "Status of resources resize desired for pod's containers. It is empty if no resources resize is pending. Any changes to container resources will automatically set this to \"Proposed\"", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ContainerStatus", "k8s.io/api/core/v1.PodCondition", "k8s.io/api/core/v1.PodIP", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_PodStatusResult(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodStatusResult is a wrapper for PodStatus returned by kubelet that can be encode/decoded", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PodTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodTemplate describes a template for creating copies of a predefined pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "template": { + SchemaProps: spec.SchemaProps{ + Description: "Template defines the pods that will be created from this pod template. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodTemplateSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodTemplateSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PodTemplateList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodTemplateList is a list of PodTemplates.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of pod templates", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodTemplate"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodTemplate", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_PodTemplateSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PodTemplateSpec describes the data a pod should have when created from a template", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_PortStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Port is the port number of the service port of which status is recorded here", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "protocol": { + SchemaProps: spec.SchemaProps{ + Description: "Protocol is the protocol of the service port of which status is recorded here The supported values are: \"TCP\", \"UDP\", \"SCTP\"\n\nPossible enum values:\n - `\"SCTP\"` is the SCTP protocol.\n - `\"TCP\"` is the TCP protocol.\n - `\"UDP\"` is the UDP protocol.", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"SCTP", "TCP", "UDP"}, + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Description: "Error is to record the problem with the service port The format of the error shall comply with the following rules: - built-in error values shall be specified in this file and those shall use\n CamelCase names\n- cloud provider specific error values must have names that comply with the\n format foo.example.com/CamelCase.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"port", "protocol"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PortworxVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PortworxVolumeSource represents a Portworx volume resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeID": { + SchemaProps: spec.SchemaProps{ + Description: "volumeID uniquely identifies a Portworx volume", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"volumeID"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_PreferAvoidPodsEntry(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Describes a class of pods that should avoid this node.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "podSignature": { + SchemaProps: spec.SchemaProps{ + Description: "The class of pods.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodSignature"), + }, + }, + "evictionTime": { + SchemaProps: spec.SchemaProps{ + Description: "Time at which this entry was added to the list.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) reason why this entry was added to the list.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Human readable message indicating why this entry was added to the list.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"podSignature"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodSignature", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_PreferredSchedulingTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "weight": { + SchemaProps: spec.SchemaProps{ + Description: "Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "preference": { + SchemaProps: spec.SchemaProps{ + Description: "A node selector term, associated with the corresponding weight.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.NodeSelectorTerm"), + }, + }, + }, + Required: []string{"weight", "preference"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSelectorTerm"}, + } +} + +func schema_k8sio_api_core_v1_Probe(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "exec": { + SchemaProps: spec.SchemaProps{ + Description: "Exec specifies the action to take.", + Ref: ref("k8s.io/api/core/v1.ExecAction"), + }, + }, + "httpGet": { + SchemaProps: spec.SchemaProps{ + Description: "HTTPGet specifies the http request to perform.", + Ref: ref("k8s.io/api/core/v1.HTTPGetAction"), + }, + }, + "tcpSocket": { + SchemaProps: spec.SchemaProps{ + Description: "TCPSocket specifies an action involving a TCP port.", + Ref: ref("k8s.io/api/core/v1.TCPSocketAction"), + }, + }, + "grpc": { + SchemaProps: spec.SchemaProps{ + Description: "GRPC specifies an action involving a GRPC port.", + Ref: ref("k8s.io/api/core/v1.GRPCAction"), + }, + }, + "initialDelaySeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "timeoutSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "periodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "successThreshold": { + SchemaProps: spec.SchemaProps{ + Description: "Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "failureThreshold": { + SchemaProps: spec.SchemaProps{ + Description: "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "terminationGracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ExecAction", "k8s.io/api/core/v1.GRPCAction", "k8s.io/api/core/v1.HTTPGetAction", "k8s.io/api/core/v1.TCPSocketAction"}, + } +} + +func schema_k8sio_api_core_v1_ProbeHandler(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ProbeHandler defines a specific action that should be taken in a probe. One and only one of the fields must be specified.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "exec": { + SchemaProps: spec.SchemaProps{ + Description: "Exec specifies the action to take.", + Ref: ref("k8s.io/api/core/v1.ExecAction"), + }, + }, + "httpGet": { + SchemaProps: spec.SchemaProps{ + Description: "HTTPGet specifies the http request to perform.", + Ref: ref("k8s.io/api/core/v1.HTTPGetAction"), + }, + }, + "tcpSocket": { + SchemaProps: spec.SchemaProps{ + Description: "TCPSocket specifies an action involving a TCP port.", + Ref: ref("k8s.io/api/core/v1.TCPSocketAction"), + }, + }, + "grpc": { + SchemaProps: spec.SchemaProps{ + Description: "GRPC specifies an action involving a GRPC port.", + Ref: ref("k8s.io/api/core/v1.GRPCAction"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ExecAction", "k8s.io/api/core/v1.GRPCAction", "k8s.io/api/core/v1.HTTPGetAction", "k8s.io/api/core/v1.TCPSocketAction"}, + } +} + +func schema_k8sio_api_core_v1_ProjectedVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a projected volume source", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "sources": { + SchemaProps: spec.SchemaProps{ + Description: "sources is the list of volume projections", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.VolumeProjection"), + }, + }, + }, + }, + }, + "defaultMode": { + SchemaProps: spec.SchemaProps{ + Description: "defaultMode are the mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.VolumeProjection"}, + } +} + +func schema_k8sio_api_core_v1_QuobyteVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Quobyte mount that lasts the lifetime of a pod. Quobyte volumes do not support ownership management or SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "registry": { + SchemaProps: spec.SchemaProps{ + Description: "registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "volume": { + SchemaProps: spec.SchemaProps{ + Description: "volume is a string that references an already created Quobyte volume by name.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Description: "user to map volume access to Defaults to serivceaccount user", + Type: []string{"string"}, + Format: "", + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Description: "group to map volume access to Default is no group", + Type: []string{"string"}, + Format: "", + }, + }, + "tenant": { + SchemaProps: spec.SchemaProps{ + Description: "tenant owning the given Quobyte volume in the Backend Used with dynamically provisioned Quobyte volumes, value is set by the plugin", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"registry", "volume"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_RBDPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "monitors": { + SchemaProps: spec.SchemaProps{ + Description: "monitors is a collection of Ceph monitors. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "image is the rados image name. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd", + Type: []string{"string"}, + Format: "", + }, + }, + "pool": { + SchemaProps: spec.SchemaProps{ + Description: "pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Description: "user is the rados user name. Default is admin. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "keyring": { + SchemaProps: spec.SchemaProps{ + Description: "keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"monitors", "image"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_RBDVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "monitors": { + SchemaProps: spec.SchemaProps{ + Description: "monitors is a collection of Ceph monitors. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "image": { + SchemaProps: spec.SchemaProps{ + Description: "image is the rados image name. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd", + Type: []string{"string"}, + Format: "", + }, + }, + "pool": { + SchemaProps: spec.SchemaProps{ + Description: "pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Description: "user is the rados user name. Default is admin. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "keyring": { + SchemaProps: spec.SchemaProps{ + Description: "keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"monitors", "image"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_RangeAllocation(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RangeAllocation is not a public type.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "range": { + SchemaProps: spec.SchemaProps{ + Description: "Range is string that identifies the range represented by 'data'.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Description: "Data is a bit array containing all allocated addresses in the previous segment.", + Type: []string{"string"}, + Format: "byte", + }, + }, + }, + Required: []string{"range", "data"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ReplicationController(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ReplicationController represents the configuration of a replication controller.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "If the Labels of a ReplicationController are empty, they are defaulted to be the same as the Pod(s) that the replication controller manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the specification of the desired behavior of the replication controller. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ReplicationControllerSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status is the most recently observed status of the replication controller. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ReplicationControllerStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ReplicationControllerSpec", "k8s.io/api/core/v1.ReplicationControllerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ReplicationControllerCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ReplicationControllerCondition describes the state of a replication controller at a certain point.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of replication controller condition.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "The last time the condition transitioned from one status to another.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "The reason for the condition's last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human readable message indicating details about the transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_ReplicationControllerList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ReplicationControllerList is a collection of replication controllers.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of replication controllers. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ReplicationController"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ReplicationController", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ReplicationControllerSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ReplicationControllerSpec is the specification of a replication controller.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "replicas": { + SchemaProps: spec.SchemaProps{ + Description: "Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "minReadySeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "selector": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Selector is a label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this replication controller, if empty defaulted to labels on Pod template. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "template": { + SchemaProps: spec.SchemaProps{ + Description: "Template is the object that describes the pod that will be created if insufficient replicas are detected. This takes precedence over a TemplateRef. The only allowed template.spec.restartPolicy value is \"Always\". More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template", + Ref: ref("k8s.io/api/core/v1.PodTemplateSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodTemplateSpec"}, + } +} + +func schema_k8sio_api_core_v1_ReplicationControllerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ReplicationControllerStatus represents the current status of a replication controller.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "replicas": { + SchemaProps: spec.SchemaProps{ + Description: "Replicas is the most recently observed number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "fullyLabeledReplicas": { + SchemaProps: spec.SchemaProps{ + Description: "The number of pods that have labels matching the labels of the pod template of the replication controller.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "readyReplicas": { + SchemaProps: spec.SchemaProps{ + Description: "The number of ready replicas for this replication controller.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "availableReplicas": { + SchemaProps: spec.SchemaProps{ + Description: "The number of available replicas (ready for at least minReadySeconds) for this replication controller.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "observedGeneration": { + SchemaProps: spec.SchemaProps{ + Description: "ObservedGeneration reflects the generation of the most recently observed replication controller.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Represents the latest available observations of a replication controller's current state.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ReplicationControllerCondition"), + }, + }, + }, + }, + }, + }, + Required: []string{"replicas"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ReplicationControllerCondition"}, + } +} + +func schema_k8sio_api_core_v1_ResourceClaim(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceClaim references one entry in PodSpec.ResourceClaims.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ResourceFieldSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "containerName": { + SchemaProps: spec.SchemaProps{ + Description: "Container name: required for volumes, optional for env vars", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Description: "Required: resource to select", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "divisor": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the output format of the exposed resources, defaults to \"1\"", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + Required: []string{"resource"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_ResourceQuota(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceQuota sets aggregate quota restrictions enforced per namespace", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the desired quota. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceQuotaSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status defines the actual enforced quota and its current usage. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceQuotaStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ResourceQuotaSpec", "k8s.io/api/core/v1.ResourceQuotaStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ResourceQuotaList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceQuotaList is a list of ResourceQuota items.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of ResourceQuota objects. More info: https://kubernetes.io/docs/concepts/policy/resource-quotas/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceQuota"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ResourceQuota", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ResourceQuotaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceQuotaSpec defines the desired hard limits to enforce for Quota.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "hard": { + SchemaProps: spec.SchemaProps{ + Description: "hard is the set of desired hard limits for each named resource. More info: https://kubernetes.io/docs/concepts/policy/resource-quotas/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "scopes": { + SchemaProps: spec.SchemaProps{ + Description: "A collection of filters that must match each object tracked by a quota. If not specified, the quota matches all objects.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "scopeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "scopeSelector is also a collection of filters like scopes that must match each object tracked by a quota but expressed using ScopeSelectorOperator in combination with possible values. For a resource to match, both scopes AND scopeSelector (if specified in spec), must be matched.", + Ref: ref("k8s.io/api/core/v1.ScopeSelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ScopeSelector", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_ResourceQuotaStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceQuotaStatus defines the enforced hard limits and observed use.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "hard": { + SchemaProps: spec.SchemaProps{ + Description: "Hard is the set of enforced hard limits for each named resource. More info: https://kubernetes.io/docs/concepts/policy/resource-quotas/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "used": { + SchemaProps: spec.SchemaProps{ + Description: "Used is the current observed total usage of the resource in the namespace.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_ResourceRequirements(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ResourceRequirements describes the compute resource requirements.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "limits": { + SchemaProps: spec.SchemaProps{ + Description: "Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "requests": { + SchemaProps: spec.SchemaProps{ + Description: "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + }, + }, + }, + "claims": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "name", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container.\n\nThis is an alpha field and requires enabling the DynamicResourceAllocation feature gate.\n\nThis field is immutable. It can only be set for containers.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceClaim"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ResourceClaim", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_k8sio_api_core_v1_SELinuxOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SELinuxOptions are the labels to be applied to the container", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "user": { + SchemaProps: spec.SchemaProps{ + Description: "User is a SELinux user label that applies to the container.", + Type: []string{"string"}, + Format: "", + }, + }, + "role": { + SchemaProps: spec.SchemaProps{ + Description: "Role is a SELinux role label that applies to the container.", + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type is a SELinux type label that applies to the container.", + Type: []string{"string"}, + Format: "", + }, + }, + "level": { + SchemaProps: spec.SchemaProps{ + Description: "Level is SELinux level label that applies to the container.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ScaleIOPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ScaleIOPersistentVolumeSource represents a persistent ScaleIO volume", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "gateway": { + SchemaProps: spec.SchemaProps{ + Description: "gateway is the host address of the ScaleIO API Gateway.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "system": { + SchemaProps: spec.SchemaProps{ + Description: "system is the name of the storage system as configured in ScaleIO.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.", + Ref: ref("k8s.io/api/core/v1.SecretReference"), + }, + }, + "sslEnabled": { + SchemaProps: spec.SchemaProps{ + Description: "sslEnabled is the flag to enable/disable SSL communication with Gateway, default false", + Type: []string{"boolean"}, + Format: "", + }, + }, + "protectionDomain": { + SchemaProps: spec.SchemaProps{ + Description: "protectionDomain is the name of the ScaleIO Protection Domain for the configured storage.", + Type: []string{"string"}, + Format: "", + }, + }, + "storagePool": { + SchemaProps: spec.SchemaProps{ + Description: "storagePool is the ScaleIO Storage Pool associated with the protection domain.", + Type: []string{"string"}, + Format: "", + }, + }, + "storageMode": { + SchemaProps: spec.SchemaProps{ + Description: "storageMode indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned.", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeName": { + SchemaProps: spec.SchemaProps{ + Description: "volumeName is the name of a volume already created in the ScaleIO system that is associated with this volume source.", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Default is \"xfs\"", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"gateway", "system", "secretRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretReference"}, + } +} + +func schema_k8sio_api_core_v1_ScaleIOVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ScaleIOVolumeSource represents a persistent ScaleIO volume", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "gateway": { + SchemaProps: spec.SchemaProps{ + Description: "gateway is the host address of the ScaleIO API Gateway.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "system": { + SchemaProps: spec.SchemaProps{ + Description: "system is the name of the storage system as configured in ScaleIO.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "sslEnabled": { + SchemaProps: spec.SchemaProps{ + Description: "sslEnabled Flag enable/disable SSL communication with Gateway, default false", + Type: []string{"boolean"}, + Format: "", + }, + }, + "protectionDomain": { + SchemaProps: spec.SchemaProps{ + Description: "protectionDomain is the name of the ScaleIO Protection Domain for the configured storage.", + Type: []string{"string"}, + Format: "", + }, + }, + "storagePool": { + SchemaProps: spec.SchemaProps{ + Description: "storagePool is the ScaleIO Storage Pool associated with the protection domain.", + Type: []string{"string"}, + Format: "", + }, + }, + "storageMode": { + SchemaProps: spec.SchemaProps{ + Description: "storageMode indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned.", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeName": { + SchemaProps: spec.SchemaProps{ + Description: "volumeName is the name of a volume already created in the ScaleIO system that is associated with this volume source.", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Default is \"xfs\".", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"gateway", "system", "secretRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_ScopeSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A scope selector represents the AND of the selectors represented by the scoped-resource selector requirements.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchExpressions": { + SchemaProps: spec.SchemaProps{ + Description: "A list of scope selector requirements by scope of the resources.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ScopedResourceSelectorRequirement"), + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ScopedResourceSelectorRequirement"}, + } +} + +func schema_k8sio_api_core_v1_ScopedResourceSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A scoped-resource selector requirement is a selector that contains values, a scope name, and an operator that relates the scope name and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "scopeName": { + SchemaProps: spec.SchemaProps{ + Description: "The name of the scope that the selector applies to.\n\nPossible enum values:\n - `\"BestEffort\"` Match all pod objects that have best effort quality of service\n - `\"CrossNamespacePodAffinity\"` Match all pod objects that have cross-namespace pod (anti)affinity mentioned.\n - `\"NotBestEffort\"` Match all pod objects that do not have best effort quality of service\n - `\"NotTerminating\"` Match all pod objects where spec.activeDeadlineSeconds is nil\n - `\"PriorityClass\"` Match all pod objects that have priority class mentioned\n - `\"Terminating\"` Match all pod objects where spec.activeDeadlineSeconds >=0", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"BestEffort", "CrossNamespacePodAffinity", "NotBestEffort", "NotTerminating", "PriorityClass", "Terminating"}, + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "Represents a scope's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist.\n\nPossible enum values:\n - `\"DoesNotExist\"`\n - `\"Exists\"`\n - `\"In\"`\n - `\"NotIn\"`", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"DoesNotExist", "Exists", "In", "NotIn"}, + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Description: "An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"scopeName", "operator"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_SeccompProfile(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SeccompProfile defines a pod/container's seccomp profile settings. Only one profile source may be set.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type indicates which kind of seccomp profile will be applied. Valid options are:\n\nLocalhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied.\n\nPossible enum values:\n - `\"Localhost\"` indicates a profile defined in a file on the node should be used. The file's location relative to /seccomp.\n - `\"RuntimeDefault\"` represents the default container runtime seccomp profile.\n - `\"Unconfined\"` indicates no seccomp profile is applied (A.K.A. unconfined).", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Localhost", "RuntimeDefault", "Unconfined"}, + }, + }, + "localhostProfile": { + SchemaProps: spec.SchemaProps{ + Description: "localhostProfile indicates a profile defined in a file on the node should be used. The profile must be preconfigured on the node to work. Must be a descending path, relative to the kubelet's configured seccomp profile location. Must only be set if type is \"Localhost\".", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-unions": []interface{}{ + map[string]interface{}{ + "discriminator": "type", + "fields-to-discriminateBy": map[string]interface{}{ + "localhostProfile": "LocalhostProfile", + }, + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Secret(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Secret holds secret data of a certain type. The total bytes of the values in the Data field must be less than MaxSecretSize bytes.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "immutable": { + SchemaProps: spec.SchemaProps{ + Description: "Immutable, if set to true, ensures that data stored in the Secret cannot be updated (only object metadata can be modified). If not set to true, the field can be modified at any time. Defaulted to nil.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Description: "Data contains the secret data. Each key must consist of alphanumeric characters, '-', '_' or '.'. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "byte", + }, + }, + }, + }, + }, + "stringData": { + SchemaProps: spec.SchemaProps{ + Description: "stringData allows specifying non-binary secret data in string form. It is provided as a write-only input field for convenience. All keys and values are merged into the data field on write, overwriting any existing values. The stringData field is never output when reading from the API.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Used to facilitate programmatic handling of secret data. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_SecretEnvSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SecretEnvSource selects a Secret to populate the environment variables with.\n\nThe contents of the target Secret's Data field will represent the key-value pairs as environment variables.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "Specify whether the Secret must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_SecretKeySelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SecretKeySelector selects a key of a Secret.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "key": { + SchemaProps: spec.SchemaProps{ + Description: "The key of the secret to select from. Must be a valid secret key.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "Specify whether the Secret or its key must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"key"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_SecretList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SecretList is a list of Secret.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of secret objects. More info: https://kubernetes.io/docs/concepts/configuration/secret", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Secret"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Secret", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_SecretProjection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adapts a secret into a projected volume.\n\nThe contents of the target Secret's Data field will be presented in a projected volume as files using the keys in the Data field as the file names. Note that this is identical to a secret volume source without the default mode.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Type: []string{"string"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items if unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.KeyToPath"), + }, + }, + }, + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "optional field specify whether the Secret or its key must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.KeyToPath"}, + } +} + +func schema_k8sio_api_core_v1_SecretReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SecretReference represents a Secret Reference. It has enough information to retrieve secret in any namespace", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is unique within a namespace to reference a secret resource.", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "namespace defines the space within which the secret name must be unique.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_SecretVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adapts a Secret into a volume.\n\nThe contents of the target Secret's Data field will be presented in a volume as files using the keys in the Data field as the file names. Secret volumes support ownership management and SELinux relabeling.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "secretName": { + SchemaProps: spec.SchemaProps{ + Description: "secretName is the name of the secret in the pod's namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + Type: []string{"string"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.KeyToPath"), + }, + }, + }, + }, + }, + "defaultMode": { + SchemaProps: spec.SchemaProps{ + Description: "defaultMode is Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "optional": { + SchemaProps: spec.SchemaProps{ + Description: "optional field specify whether the Secret or its keys must be defined", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.KeyToPath"}, + } +} + +func schema_k8sio_api_core_v1_SecurityContext(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext holds security configuration that will be applied to a container. Some fields are present in both SecurityContext and PodSecurityContext. When both are set, the values in SecurityContext take precedence.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "capabilities": { + SchemaProps: spec.SchemaProps{ + Description: "The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime. Note that this field cannot be set when spec.os.name is windows.", + Ref: ref("k8s.io/api/core/v1.Capabilities"), + }, + }, + "privileged": { + SchemaProps: spec.SchemaProps{ + Description: "Run container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host. Defaults to false. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "seLinuxOptions": { + SchemaProps: spec.SchemaProps{ + Description: "The SELinux context to be applied to the container. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows.", + Ref: ref("k8s.io/api/core/v1.SELinuxOptions"), + }, + }, + "windowsOptions": { + SchemaProps: spec.SchemaProps{ + Description: "The Windows specific settings applied to all containers. If unspecified, the options from the PodSecurityContext will be used. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is linux.", + Ref: ref("k8s.io/api/core/v1.WindowsSecurityContextOptions"), + }, + }, + "runAsUser": { + SchemaProps: spec.SchemaProps{ + Description: "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "runAsGroup": { + SchemaProps: spec.SchemaProps{ + Description: "The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "runAsNonRoot": { + SchemaProps: spec.SchemaProps{ + Description: "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "readOnlyRootFilesystem": { + SchemaProps: spec.SchemaProps{ + Description: "Whether this container has a read-only root filesystem. Default is false. Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "allowPrivilegeEscalation": { + SchemaProps: spec.SchemaProps{ + Description: "AllowPrivilegeEscalation controls whether a process can gain more privileges than its parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN Note that this field cannot be set when spec.os.name is windows.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "procMount": { + SchemaProps: spec.SchemaProps{ + Description: "procMount denotes the type of proc mount to use for the containers. The default is DefaultProcMount which uses the container runtime defaults for readonly paths and masked paths. This requires the ProcMountType feature flag to be enabled. Note that this field cannot be set when spec.os.name is windows.\n\nPossible enum values:\n - `\"Default\"` uses the container runtime defaults for readonly and masked paths for /proc. Most container runtimes mask certain paths in /proc to avoid accidental security exposure of special devices or information.\n - `\"Unmasked\"` bypasses the default masking behavior of the container runtime and ensures the newly created /proc the container stays in tact with no modifications.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Default", "Unmasked"}, + }, + }, + "seccompProfile": { + SchemaProps: spec.SchemaProps{ + Description: "The seccomp options to use by this container. If seccomp options are provided at both the pod & container level, the container options override the pod options. Note that this field cannot be set when spec.os.name is windows.", + Ref: ref("k8s.io/api/core/v1.SeccompProfile"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Capabilities", "k8s.io/api/core/v1.SELinuxOptions", "k8s.io/api/core/v1.SeccompProfile", "k8s.io/api/core/v1.WindowsSecurityContextOptions"}, + } +} + +func schema_k8sio_api_core_v1_SerializedReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SerializedReference is a reference to serialized object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "reference": { + SchemaProps: spec.SchemaProps{ + Description: "The reference to an object in the system.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_Service(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Service is a named abstraction of software service (for example, mysql) consisting of local port (for example 3306) that the proxy listens on, and the selector that determines which pods will answer requests sent through the proxy.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec defines the behavior of a service. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ServiceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Most recently observed status of the service. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ServiceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ServiceSpec", "k8s.io/api/core/v1.ServiceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ServiceAccount(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccount binds together: * a name, understood by users, and perhaps by peripheral systems, for an identity * a principal that can be authenticated and authorized * a set of secrets", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "secrets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Secrets is a list of the secrets in the same namespace that pods running using this ServiceAccount are allowed to use. Pods are only limited to this list if this service account has a \"kubernetes.io/enforce-mountable-secrets\" annotation set to \"true\". This field should not be used to find auto-generated service account token secrets for use outside of pods. Instead, tokens can be requested directly using the TokenRequest API, or service account token secrets can be manually created. More info: https://kubernetes.io/docs/concepts/configuration/secret", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + }, + }, + "imagePullSecrets": { + SchemaProps: spec.SchemaProps{ + Description: "ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling any images in pods that reference this ServiceAccount. ImagePullSecrets are distinct from Secrets because Secrets can be mounted in the pod, but ImagePullSecrets are only accessed by the kubelet. More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + "automountServiceAccountToken": { + SchemaProps: spec.SchemaProps{ + Description: "AutomountServiceAccountToken indicates whether pods running as this service account should have an API token automatically mounted. Can be overridden at the pod level.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.ObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_k8sio_api_core_v1_ServiceAccountList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountList is a list of ServiceAccount objects", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of ServiceAccounts. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ServiceAccount"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ServiceAccount", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ServiceAccountTokenProjection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountTokenProjection represents a projected service account token volume. This projection can be used to insert a service account token into the pods runtime filesystem for use against APIs (Kubernetes API Server or otherwise).", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "audience": { + SchemaProps: spec.SchemaProps{ + Description: "audience is the intended audience of the token. A recipient of a token must identify itself with an identifier specified in the audience of the token, and otherwise should reject the token. The audience defaults to the identifier of the apiserver.", + Type: []string{"string"}, + Format: "", + }, + }, + "expirationSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "expirationSeconds is the requested duration of validity of the service account token. As the token approaches expiration, the kubelet volume plugin will proactively rotate the service account token. The kubelet will start trying to rotate the token if the token is older than 80 percent of its time to live or if the token is older than 24 hours.Defaults to 1 hour and must be at least 10 minutes.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "path is the path relative to the mount point of the file to project the token into.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"path"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ServiceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceList holds a list of services.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of services", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Service"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Service", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_k8sio_api_core_v1_ServicePort(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServicePort contains information on service's port.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort. Optional if only one ServicePort is defined on this service.", + Type: []string{"string"}, + Format: "", + }, + }, + "protocol": { + SchemaProps: spec.SchemaProps{ + Description: "The IP protocol for this port. Supports \"TCP\", \"UDP\", and \"SCTP\". Default is TCP.\n\nPossible enum values:\n - `\"SCTP\"` is the SCTP protocol.\n - `\"TCP\"` is the TCP protocol.\n - `\"UDP\"` is the UDP protocol.", + Default: "TCP", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"SCTP", "TCP", "UDP"}, + }, + }, + "appProtocol": { + SchemaProps: spec.SchemaProps{ + Description: "The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.", + Type: []string{"string"}, + Format: "", + }, + }, + "port": { + SchemaProps: spec.SchemaProps{ + Description: "The port that will be exposed by this service.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "targetPort": { + SchemaProps: spec.SchemaProps{ + Description: "Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/util/intstr.IntOrString"), + }, + }, + "nodePort": { + SchemaProps: spec.SchemaProps{ + Description: "The port on each node on which this service is exposed when type is NodePort or LoadBalancer. Usually assigned by the system. If a value is specified, in-range, and not in use it will be used, otherwise the operation will fail. If not specified, a port will be allocated if this Service requires one. If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"port"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/util/intstr.IntOrString"}, + } +} + +func schema_k8sio_api_core_v1_ServiceProxyOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceProxyOptions is the query options to a Service's proxy call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Path is the part of URLs that include service endpoints, suffixes, and parameters to use for the current proxy request to service. For example, the whole request URL is http://localhost/api/v1/namespaces/kube-system/services/elasticsearch-logging/_search?q=user:kimchy. Path is _search?q=user:kimchy.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_ServiceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceSpec describes the attributes that a user creates on a service.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ports": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "port", + "protocol", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "port", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ServicePort"), + }, + }, + }, + }, + }, + "selector": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "clusterIP": { + SchemaProps: spec.SchemaProps{ + Description: "clusterIP is the IP address of the service and is usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be blank) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are \"None\", empty string (\"\"), or a valid IP address. Setting this to \"None\" makes a \"headless service\" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + Type: []string{"string"}, + Format: "", + }, + }, + "clusterIPs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ClusterIPs is a list of IP addresses assigned to this service, and are usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be empty) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are \"None\", empty string (\"\"), or a valid IP address. Setting this to \"None\" makes a \"headless service\" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. If this field is not specified, it will be initialized from the clusterIP field. If this field is specified, clients must ensure that clusterIPs[0] and clusterIP have the same value.\n\nThis field may hold a maximum of two entries (dual-stack IPs, in either order). These IPs must correspond to the values of the ipFamilies field. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object or EndpointSlice objects. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a virtual IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the same endpoints as the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the same endpoints as the clusterIP. \"ExternalName\" aliases this service to the specified externalName. Several other fields do not apply to ExternalName services. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types\n\nPossible enum values:\n - `\"ClusterIP\"` means a service will only be accessible inside the cluster, via the cluster IP.\n - `\"ExternalName\"` means a service consists of only a reference to an external name that kubedns or equivalent will return as a CNAME record, with no exposing or proxying of any pods involved.\n - `\"LoadBalancer\"` means a service will be exposed via an external load balancer (if the cloud provider supports it), in addition to 'NodePort' type.\n - `\"NodePort\"` means a service will be exposed on one port of every node, in addition to 'ClusterIP' type.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"ClusterIP", "ExternalName", "LoadBalancer", "NodePort"}, + }, + }, + "externalIPs": { + SchemaProps: spec.SchemaProps{ + Description: "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "sessionAffinity": { + SchemaProps: spec.SchemaProps{ + Description: "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies\n\nPossible enum values:\n - `\"ClientIP\"` is the Client IP based.\n - `\"None\"` - no session affinity.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"ClientIP", "None"}, + }, + }, + "loadBalancerIP": { + SchemaProps: spec.SchemaProps{ + Description: "Only applies to Service Type: LoadBalancer. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature. Deprecated: This field was under-specified and its meaning varies across implementations, and it cannot support dual-stack. As of Kubernetes v1.24, users are encouraged to use implementation-specific annotations when available. This field may be removed in a future API version.", + Type: []string{"string"}, + Format: "", + }, + }, + "loadBalancerSourceRanges": { + SchemaProps: spec.SchemaProps{ + Description: "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "externalName": { + SchemaProps: spec.SchemaProps{ + Description: "externalName is the external reference that discovery mechanisms will return as an alias for this service (e.g. a DNS CNAME record). No proxying will be involved. Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) and requires `type` to be \"ExternalName\".", + Type: []string{"string"}, + Format: "", + }, + }, + "externalTrafficPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "externalTrafficPolicy describes how nodes distribute service traffic they receive on one of the Service's \"externally-facing\" addresses (NodePorts, ExternalIPs, and LoadBalancer IPs). If set to \"Local\", the proxy will configure the service in a way that assumes that external load balancers will take care of balancing the service traffic between nodes, and so each node will deliver traffic only to the node-local endpoints of the service, without masquerading the client source IP. (Traffic mistakenly sent to a node with no endpoints will be dropped.) The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features). Note that traffic sent to an External IP or LoadBalancer IP from within the cluster will always get \"Cluster\" semantics, but clients sending to a NodePort from within the cluster may need to take traffic policy into account when picking a node.\n\nPossible enum values:\n - `\"Cluster\"`\n - `\"Cluster\"` routes traffic to all endpoints.\n - `\"Local\"`\n - `\"Local\"` preserves the source IP of the traffic by routing only to endpoints on the same node as the traffic was received on (dropping the traffic if there are no local endpoints).", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Cluster", "Cluster", "Local", "Local"}, + }, + }, + "healthCheckNodePort": { + SchemaProps: spec.SchemaProps{ + Description: "healthCheckNodePort specifies the healthcheck nodePort for the service. This only applies when type is set to LoadBalancer and externalTrafficPolicy is set to Local. If a value is specified, is in-range, and is not in use, it will be used. If not specified, a value will be automatically allocated. External systems (e.g. load-balancers) can use this port to determine if a given node holds endpoints for this service or not. If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type). This field cannot be updated once set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "publishNotReadyAddresses": { + SchemaProps: spec.SchemaProps{ + Description: "publishNotReadyAddresses indicates that any agent which deals with endpoints for this Service should disregard any indications of ready/not-ready. The primary use case for setting this field is for a StatefulSet's Headless Service to propagate SRV DNS records for its Pods for the purpose of peer discovery. The Kubernetes controllers that generate Endpoints and EndpointSlice resources for Services interpret this to mean that all endpoints are considered \"ready\" even if the Pods themselves are not. Agents which consume only Kubernetes generated endpoints through the Endpoints or EndpointSlice resources can safely assume this behavior.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "sessionAffinityConfig": { + SchemaProps: spec.SchemaProps{ + Description: "sessionAffinityConfig contains the configurations of session affinity.", + Ref: ref("k8s.io/api/core/v1.SessionAffinityConfig"), + }, + }, + "ipFamilies": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "IPFamilies is a list of IP families (e.g. IPv4, IPv6) assigned to this service. This field is usually assigned automatically based on cluster configuration and the ipFamilyPolicy field. If this field is specified manually, the requested family is available in the cluster, and ipFamilyPolicy allows it, it will be used; otherwise creation of the service will fail. This field is conditionally mutable: it allows for adding or removing a secondary IP family, but it does not allow changing the primary IP family of the Service. Valid values are \"IPv4\" and \"IPv6\". This field only applies to Services of types ClusterIP, NodePort, and LoadBalancer, and does apply to \"headless\" services. This field will be wiped when updating a Service to type ExternalName.\n\nThis field may hold a maximum of two entries (dual-stack families, in either order). These families must correspond to the values of the clusterIPs field, if specified. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "ipFamilyPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "IPFamilyPolicy represents the dual-stack-ness requested or required by this Service. If there is no value provided, then this field will be set to SingleStack. Services can be \"SingleStack\" (a single IP family), \"PreferDualStack\" (two IP families on dual-stack configured clusters or a single IP family on single-stack clusters), or \"RequireDualStack\" (two IP families on dual-stack configured clusters, otherwise fail). The ipFamilies and clusterIPs fields depend on the value of this field. This field will be wiped when updating a service to type ExternalName.\n\nPossible enum values:\n - `\"PreferDualStack\"` indicates that this service prefers dual-stack when the cluster is configured for dual-stack. If the cluster is not configured for dual-stack the service will be assigned a single IPFamily. If the IPFamily is not set in service.spec.ipFamilies then the service will be assigned the default IPFamily configured on the cluster\n - `\"RequireDualStack\"` indicates that this service requires dual-stack. Using IPFamilyPolicyRequireDualStack on a single stack cluster will result in validation errors. The IPFamilies (and their order) assigned to this service is based on service.spec.ipFamilies. If service.spec.ipFamilies was not provided then it will be assigned according to how they are configured on the cluster. If service.spec.ipFamilies has only one entry then the alternative IPFamily will be added by apiserver\n - `\"SingleStack\"` indicates that this service is required to have a single IPFamily. The IPFamily assigned is based on the default IPFamily used by the cluster or as identified by service.spec.ipFamilies field", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"PreferDualStack", "RequireDualStack", "SingleStack"}, + }, + }, + "allocateLoadBalancerNodePorts": { + SchemaProps: spec.SchemaProps{ + Description: "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "loadBalancerClass": { + SchemaProps: spec.SchemaProps{ + Description: "loadBalancerClass is the class of the load balancer implementation this Service belongs to. If specified, the value of this field must be a label-style identifier, with an optional prefix, e.g. \"internal-vip\" or \"example.com/internal-vip\". Unprefixed names are reserved for end-users. This field can only be set when the Service type is 'LoadBalancer'. If not set, the default load balancer implementation is used, today this is typically done through the cloud provider integration, but should apply for any default implementation. If set, it is assumed that a load balancer implementation is watching for Services with a matching class. Any default load balancer implementation (e.g. cloud providers) should ignore Services that set this field. This field can only be set when creating or updating a Service to type 'LoadBalancer'. Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type.", + Type: []string{"string"}, + Format: "", + }, + }, + "internalTrafficPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "InternalTrafficPolicy describes how nodes distribute service traffic they receive on the ClusterIP. If set to \"Local\", the proxy will assume that pods only want to talk to endpoints of the service on the same node as the pod, dropping the traffic if there are no local endpoints. The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features).\n\nPossible enum values:\n - `\"Cluster\"` routes traffic to all endpoints.\n - `\"Local\"` routes traffic only to endpoints on the same node as the client pod (dropping the traffic if there are no local endpoints).", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Cluster", "Local"}, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ServicePort", "k8s.io/api/core/v1.SessionAffinityConfig"}, + } +} + +func schema_k8sio_api_core_v1_ServiceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServiceStatus represents the current status of a service.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "loadBalancer": { + SchemaProps: spec.SchemaProps{ + Description: "LoadBalancer contains the current status of the load-balancer, if one is present.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LoadBalancerStatus"), + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Current service state", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LoadBalancerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + } +} + +func schema_k8sio_api_core_v1_SessionAffinityConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SessionAffinityConfig represents the configurations of session affinity.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "clientIP": { + SchemaProps: spec.SchemaProps{ + Description: "clientIP contains the configurations of Client IP based session affinity.", + Ref: ref("k8s.io/api/core/v1.ClientIPConfig"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ClientIPConfig"}, + } +} + +func schema_k8sio_api_core_v1_StorageOSPersistentVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a StorageOS persistent volume resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeName": { + SchemaProps: spec.SchemaProps{ + Description: "volumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "volumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_StorageOSVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a StorageOS persistent volume resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeName": { + SchemaProps: spec.SchemaProps{ + Description: "volumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + Type: []string{"string"}, + Format: "", + }, + }, + "volumeNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "volumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "secretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_k8sio_api_core_v1_Sysctl(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Sysctl defines a kernel parameter to be set", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of a property to set", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value of a property to set", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "value"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_TCPSocketAction(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TCPSocketAction describes an action based on opening a socket", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "port": { + SchemaProps: spec.SchemaProps{ + Description: "Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/util/intstr.IntOrString"), + }, + }, + "host": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Host name to connect to, defaults to the pod IP.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"port"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/util/intstr.IntOrString"}, + } +} + +func schema_k8sio_api_core_v1_Taint(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "The node this Taint is attached to has the \"effect\" on any pod that does not tolerate the Taint.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "Required. The taint key to be applied to a node.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "The taint value corresponding to the taint key.", + Type: []string{"string"}, + Format: "", + }, + }, + "effect": { + SchemaProps: spec.SchemaProps{ + Description: "Required. The effect of the taint on pods that do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule and NoExecute.\n\nPossible enum values:\n - `\"NoExecute\"` Evict any already-running pods that do not tolerate the taint. Currently enforced by NodeController.\n - `\"NoSchedule\"` Do not allow new pods to schedule onto the node unless they tolerate the taint, but allow all pods submitted to Kubelet without going through the scheduler to start, and allow all already-running pods to continue running. Enforced by the scheduler.\n - `\"PreferNoSchedule\"` Like TaintEffectNoSchedule, but the scheduler tries not to schedule new pods onto the node, rather than prohibiting new pods from scheduling onto the node entirely. Enforced by the scheduler.", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"NoExecute", "NoSchedule", "PreferNoSchedule"}, + }, + }, + "timeAdded": { + SchemaProps: spec.SchemaProps{ + Description: "TimeAdded represents the time at which the taint was added. It is only written for NoExecute taints.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + }, + Required: []string{"key", "effect"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_k8sio_api_core_v1_Toleration(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator .", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.\n\nPossible enum values:\n - `\"Equal\"`\n - `\"Exists\"`", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Equal", "Exists"}, + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.", + Type: []string{"string"}, + Format: "", + }, + }, + "effect": { + SchemaProps: spec.SchemaProps{ + Description: "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.\n\nPossible enum values:\n - `\"NoExecute\"` Evict any already-running pods that do not tolerate the taint. Currently enforced by NodeController.\n - `\"NoSchedule\"` Do not allow new pods to schedule onto the node unless they tolerate the taint, but allow all pods submitted to Kubelet without going through the scheduler to start, and allow all already-running pods to continue running. Enforced by the scheduler.\n - `\"PreferNoSchedule\"` Like TaintEffectNoSchedule, but the scheduler tries not to schedule new pods onto the node, rather than prohibiting new pods from scheduling onto the node entirely. Enforced by the scheduler.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"NoExecute", "NoSchedule", "PreferNoSchedule"}, + }, + }, + "tolerationSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_TopologySelectorLabelRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A topology selector requirement is a selector that matches given label. This is an alpha feature and may change in the future.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "The label key that the selector applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Description: "An array of string values. One value must match the label to be selected. Each entry in Values is ORed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "values"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_TopologySelectorTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A topology selector term represents the result of label queries. A null or empty topology selector term matches no objects. The requirements of them are ANDed. It provides a subset of functionality as NodeSelectorTerm. This is an alpha feature and may change in the future.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchLabelExpressions": { + SchemaProps: spec.SchemaProps{ + Description: "A list of topology selector requirements by labels.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.TopologySelectorLabelRequirement"), + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.TopologySelectorLabelRequirement"}, + } +} + +func schema_k8sio_api_core_v1_TopologySpreadConstraint(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TopologySpreadConstraint specifies how to spread matching pods among the given topology.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "maxSkew": { + SchemaProps: spec.SchemaProps{ + Description: "MaxSkew describes the degree to which pods may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference between the number of matching pods in the target topology and the global minimum. The global minimum is the minimum number of matching pods in an eligible domain or zero if the number of eligible domains is less than MinDomains. For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same labelSelector spread as 2/2/1: In this case, the global minimum is 1. | zone1 | zone2 | zone3 | | P P | P P | P | - if MaxSkew is 1, incoming pod can only be scheduled to zone3 to become 2/2/2; scheduling it onto zone1(zone2) would make the ActualSkew(3-1) on zone1(zone2) violate MaxSkew(1). - if MaxSkew is 2, incoming pod can be scheduled onto any zone. When `whenUnsatisfiable=ScheduleAnyway`, it is used to give higher precedence to topologies that satisfy it. It's a required field. Default value is 1 and 0 is not allowed.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "topologyKey": { + SchemaProps: spec.SchemaProps{ + Description: "TopologyKey is the key of node labels. Nodes that have a label with this key and identical values are considered to be in the same topology. We consider each as a \"bucket\", and try to put balanced number of pods into each bucket. We define a domain as a particular instance of a topology. Also, we define an eligible domain as a domain whose nodes meet the requirements of nodeAffinityPolicy and nodeTaintsPolicy. e.g. If TopologyKey is \"kubernetes.io/hostname\", each Node is a domain of that topology. And, if TopologyKey is \"topology.kubernetes.io/zone\", each zone is a domain of that topology. It's a required field.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "whenUnsatisfiable": { + SchemaProps: spec.SchemaProps{ + Description: "WhenUnsatisfiable indicates how to deal with a pod if it doesn't satisfy the spread constraint. - DoNotSchedule (default) tells the scheduler not to schedule it. - ScheduleAnyway tells the scheduler to schedule the pod in any location,\n but giving higher precedence to topologies that would help reduce the\n skew.\nA constraint is considered \"Unsatisfiable\" for an incoming pod if and only if every possible node assignment for that pod would violate \"MaxSkew\" on some topology. For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same labelSelector spread as 3/1/1: | zone1 | zone2 | zone3 | | P P P | P | P | If WhenUnsatisfiable is set to DoNotSchedule, incoming pod can only be scheduled to zone2(zone3) to become 3/2/1(3/1/2) as ActualSkew(2-1) on zone2(zone3) satisfies MaxSkew(1). In other words, the cluster can still be imbalanced, but scheduler won't make it *more* imbalanced. It's a required field.\n\nPossible enum values:\n - `\"DoNotSchedule\"` instructs the scheduler not to schedule the pod when constraints are not satisfied.\n - `\"ScheduleAnyway\"` instructs the scheduler to schedule the pod even if constraints are not satisfied.", + Default: "", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"DoNotSchedule", "ScheduleAnyway"}, + }, + }, + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "LabelSelector is used to find matching pods. Pods that match this label selector are counted to determine the number of pods in their corresponding topology domain.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + "minDomains": { + SchemaProps: spec.SchemaProps{ + Description: "MinDomains indicates a minimum number of eligible domains. When the number of eligible domains with matching topology keys is less than minDomains, Pod Topology Spread treats \"global minimum\" as 0, and then the calculation of Skew is performed. And when the number of eligible domains with matching topology keys equals or greater than minDomains, this value has no effect on scheduling. As a result, when the number of eligible domains is less than minDomains, scheduler won't schedule more than maxSkew Pods to those domains. If value is nil, the constraint behaves as if MinDomains is equal to 1. Valid values are integers greater than 0. When value is not nil, WhenUnsatisfiable must be DoNotSchedule.\n\nFor example, in a 3-zone cluster, MaxSkew is set to 2, MinDomains is set to 5 and pods with the same labelSelector spread as 2/2/2: | zone1 | zone2 | zone3 | | P P | P P | P P | The number of domains is less than 5(MinDomains), so \"global minimum\" is treated as 0. In this situation, new pod with the same labelSelector cannot be scheduled, because computed skew will be 3(3 - 0) if new Pod is scheduled to any of the three zones, it will violate MaxSkew.\n\nThis is a beta field and requires the MinDomainsInPodTopologySpread feature gate to be enabled (enabled by default).", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "nodeAffinityPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew. Options are: - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations. - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations.\n\nIf this value is nil, the behavior is equivalent to the Honor policy. This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.\n\nPossible enum values:\n - `\"Honor\"` means use this scheduling directive when calculating pod topology spread skew.\n - `\"Ignore\"` means ignore this scheduling directive when calculating pod topology spread skew.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Honor", "Ignore"}, + }, + }, + "nodeTaintsPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "NodeTaintsPolicy indicates how we will treat node taints when calculating pod topology spread skew. Options are: - Honor: nodes without taints, along with tainted nodes for which the incoming pod has a toleration, are included. - Ignore: node taints are ignored. All nodes are included.\n\nIf this value is nil, the behavior is equivalent to the Ignore policy. This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.\n\nPossible enum values:\n - `\"Honor\"` means use this scheduling directive when calculating pod topology spread skew.\n - `\"Ignore\"` means ignore this scheduling directive when calculating pod topology spread skew.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Honor", "Ignore"}, + }, + }, + "matchLabelKeys": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "MatchLabelKeys is a set of pod label keys to select the pods over which spreading will be calculated. The keys are used to lookup values from the incoming pod labels, those key-value labels are ANDed with labelSelector to select the group of existing pods over which spreading will be calculated for the incoming pod. The same key is forbidden to exist in both MatchLabelKeys and LabelSelector. MatchLabelKeys cannot be set when LabelSelector isn't set. Keys that don't exist in the incoming pod labels will be ignored. A null or empty list means only match against labelSelector.\n\nThis is a beta field and requires the MatchLabelKeysInPodTopologySpread feature gate to be enabled (enabled by default).", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"maxSkew", "topologyKey", "whenUnsatisfiable"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + +func schema_k8sio_api_core_v1_TypedLocalObjectReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiGroup": { + SchemaProps: spec.SchemaProps{ + Description: "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is the type of resource being referenced", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of resource being referenced", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"kind", "name"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_k8sio_api_core_v1_TypedObjectReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiGroup": { + SchemaProps: spec.SchemaProps{ + Description: "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is the type of resource being referenced", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name is the name of resource being referenced", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace is the namespace of resource being referenced Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. (Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"kind", "name"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_Volume(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Volume represents a named volume in a pod that may be accessed by any container in the pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "hostPath": { + SchemaProps: spec.SchemaProps{ + Description: "hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + Ref: ref("k8s.io/api/core/v1.HostPathVolumeSource"), + }, + }, + "emptyDir": { + SchemaProps: spec.SchemaProps{ + Description: "emptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + Ref: ref("k8s.io/api/core/v1.EmptyDirVolumeSource"), + }, + }, + "gcePersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Ref: ref("k8s.io/api/core/v1.GCEPersistentDiskVolumeSource"), + }, + }, + "awsElasticBlockStore": { + SchemaProps: spec.SchemaProps{ + Description: "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Ref: ref("k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource"), + }, + }, + "gitRepo": { + SchemaProps: spec.SchemaProps{ + Description: "gitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.", + Ref: ref("k8s.io/api/core/v1.GitRepoVolumeSource"), + }, + }, + "secret": { + SchemaProps: spec.SchemaProps{ + Description: "secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + Ref: ref("k8s.io/api/core/v1.SecretVolumeSource"), + }, + }, + "nfs": { + SchemaProps: spec.SchemaProps{ + Description: "nfs represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Ref: ref("k8s.io/api/core/v1.NFSVolumeSource"), + }, + }, + "iscsi": { + SchemaProps: spec.SchemaProps{ + Description: "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md", + Ref: ref("k8s.io/api/core/v1.ISCSIVolumeSource"), + }, + }, + "glusterfs": { + SchemaProps: spec.SchemaProps{ + Description: "glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md", + Ref: ref("k8s.io/api/core/v1.GlusterfsVolumeSource"), + }, + }, + "persistentVolumeClaim": { + SchemaProps: spec.SchemaProps{ + Description: "persistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource"), + }, + }, + "rbd": { + SchemaProps: spec.SchemaProps{ + Description: "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md", + Ref: ref("k8s.io/api/core/v1.RBDVolumeSource"), + }, + }, + "flexVolume": { + SchemaProps: spec.SchemaProps{ + Description: "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.", + Ref: ref("k8s.io/api/core/v1.FlexVolumeSource"), + }, + }, + "cinder": { + SchemaProps: spec.SchemaProps{ + Description: "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Ref: ref("k8s.io/api/core/v1.CinderVolumeSource"), + }, + }, + "cephfs": { + SchemaProps: spec.SchemaProps{ + Description: "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.CephFSVolumeSource"), + }, + }, + "flocker": { + SchemaProps: spec.SchemaProps{ + Description: "flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running", + Ref: ref("k8s.io/api/core/v1.FlockerVolumeSource"), + }, + }, + "downwardAPI": { + SchemaProps: spec.SchemaProps{ + Description: "downwardAPI represents downward API about the pod that should populate this volume", + Ref: ref("k8s.io/api/core/v1.DownwardAPIVolumeSource"), + }, + }, + "fc": { + SchemaProps: spec.SchemaProps{ + Description: "fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + Ref: ref("k8s.io/api/core/v1.FCVolumeSource"), + }, + }, + "azureFile": { + SchemaProps: spec.SchemaProps{ + Description: "azureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureFileVolumeSource"), + }, + }, + "configMap": { + SchemaProps: spec.SchemaProps{ + Description: "configMap represents a configMap that should populate this volume", + Ref: ref("k8s.io/api/core/v1.ConfigMapVolumeSource"), + }, + }, + "vsphereVolume": { + SchemaProps: spec.SchemaProps{ + Description: "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"), + }, + }, + "quobyte": { + SchemaProps: spec.SchemaProps{ + Description: "quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.QuobyteVolumeSource"), + }, + }, + "azureDisk": { + SchemaProps: spec.SchemaProps{ + Description: "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureDiskVolumeSource"), + }, + }, + "photonPersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource"), + }, + }, + "projected": { + SchemaProps: spec.SchemaProps{ + Description: "projected items for all in one resources secrets, configmaps, and downward API", + Ref: ref("k8s.io/api/core/v1.ProjectedVolumeSource"), + }, + }, + "portworxVolume": { + SchemaProps: spec.SchemaProps{ + Description: "portworxVolume represents a portworx volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PortworxVolumeSource"), + }, + }, + "scaleIO": { + SchemaProps: spec.SchemaProps{ + Description: "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.ScaleIOVolumeSource"), + }, + }, + "storageos": { + SchemaProps: spec.SchemaProps{ + Description: "storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.StorageOSVolumeSource"), + }, + }, + "csi": { + SchemaProps: spec.SchemaProps{ + Description: "csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).", + Ref: ref("k8s.io/api/core/v1.CSIVolumeSource"), + }, + }, + "ephemeral": { + SchemaProps: spec.SchemaProps{ + Description: "ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed.\n\nUse this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity\n tracking are needed,\nc) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through\n a PersistentVolumeClaim (see EphemeralVolumeSource for more\n information on the connection between this volume type\n and PersistentVolumeClaim).\n\nUse PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod.\n\nUse CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information.\n\nA pod can use both types of ephemeral volumes and persistent volumes at the same time.", + Ref: ref("k8s.io/api/core/v1.EphemeralVolumeSource"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource", "k8s.io/api/core/v1.AzureDiskVolumeSource", "k8s.io/api/core/v1.AzureFileVolumeSource", "k8s.io/api/core/v1.CSIVolumeSource", "k8s.io/api/core/v1.CephFSVolumeSource", "k8s.io/api/core/v1.CinderVolumeSource", "k8s.io/api/core/v1.ConfigMapVolumeSource", "k8s.io/api/core/v1.DownwardAPIVolumeSource", "k8s.io/api/core/v1.EmptyDirVolumeSource", "k8s.io/api/core/v1.EphemeralVolumeSource", "k8s.io/api/core/v1.FCVolumeSource", "k8s.io/api/core/v1.FlexVolumeSource", "k8s.io/api/core/v1.FlockerVolumeSource", "k8s.io/api/core/v1.GCEPersistentDiskVolumeSource", "k8s.io/api/core/v1.GitRepoVolumeSource", "k8s.io/api/core/v1.GlusterfsVolumeSource", "k8s.io/api/core/v1.HostPathVolumeSource", "k8s.io/api/core/v1.ISCSIVolumeSource", "k8s.io/api/core/v1.NFSVolumeSource", "k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource", "k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource", "k8s.io/api/core/v1.PortworxVolumeSource", "k8s.io/api/core/v1.ProjectedVolumeSource", "k8s.io/api/core/v1.QuobyteVolumeSource", "k8s.io/api/core/v1.RBDVolumeSource", "k8s.io/api/core/v1.ScaleIOVolumeSource", "k8s.io/api/core/v1.SecretVolumeSource", "k8s.io/api/core/v1.StorageOSVolumeSource", "k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"}, + } +} + +func schema_k8sio_api_core_v1_VolumeDevice(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "volumeDevice describes a mapping of a raw block device within a container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name must match the name of a persistentVolumeClaim in the pod", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "devicePath": { + SchemaProps: spec.SchemaProps{ + Description: "devicePath is the path inside of the container that the device will be mapped to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "devicePath"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_VolumeMount(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "VolumeMount describes a mounting of a Volume within a container.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "This must match the Name of a Volume.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Description: "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "mountPath": { + SchemaProps: spec.SchemaProps{ + Description: "Path within the container at which the volume should be mounted. Must not contain ':'.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "subPath": { + SchemaProps: spec.SchemaProps{ + Description: "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root).", + Type: []string{"string"}, + Format: "", + }, + }, + "mountPropagation": { + SchemaProps: spec.SchemaProps{ + Description: "mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10.\n\nPossible enum values:\n - `\"Bidirectional\"` means that the volume in a container will receive new mounts from the host or other containers, and its own mounts will be propagated from the container to the host or other containers. Note that this mode is recursively applied to all mounts in the volume (\"rshared\" in Linux terminology).\n - `\"HostToContainer\"` means that the volume in a container will receive new mounts from the host or other containers, but filesystems mounted inside the container won't be propagated to the host or other containers. Note that this mode is recursively applied to all mounts in the volume (\"rslave\" in Linux terminology).\n - `\"None\"` means that the volume in a container will not receive new mounts from the host or other containers, and filesystems mounted inside the container won't be propagated to the host or other containers. Note that this mode corresponds to \"private\" in Linux terminology.", + Type: []string{"string"}, + Format: "", + Enum: []interface{}{"Bidirectional", "HostToContainer", "None"}, + }, + }, + "subPathExpr": { + SchemaProps: spec.SchemaProps{ + Description: "Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to \"\" (volume's root). SubPathExpr and SubPath are mutually exclusive.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "mountPath"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_VolumeNodeAffinity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "VolumeNodeAffinity defines constraints that limit what nodes this volume can be accessed from.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "required": { + SchemaProps: spec.SchemaProps{ + Description: "required specifies hard node constraints that must be met.", + Ref: ref("k8s.io/api/core/v1.NodeSelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.NodeSelector"}, + } +} + +func schema_k8sio_api_core_v1_VolumeProjection(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Projection that may be projected along with other supported volume types", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "secret": { + SchemaProps: spec.SchemaProps{ + Description: "secret information about the secret data to project", + Ref: ref("k8s.io/api/core/v1.SecretProjection"), + }, + }, + "downwardAPI": { + SchemaProps: spec.SchemaProps{ + Description: "downwardAPI information about the downwardAPI data to project", + Ref: ref("k8s.io/api/core/v1.DownwardAPIProjection"), + }, + }, + "configMap": { + SchemaProps: spec.SchemaProps{ + Description: "configMap information about the configMap data to project", + Ref: ref("k8s.io/api/core/v1.ConfigMapProjection"), + }, + }, + "serviceAccountToken": { + SchemaProps: spec.SchemaProps{ + Description: "serviceAccountToken is information about the serviceAccountToken data to project", + Ref: ref("k8s.io/api/core/v1.ServiceAccountTokenProjection"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ConfigMapProjection", "k8s.io/api/core/v1.DownwardAPIProjection", "k8s.io/api/core/v1.SecretProjection", "k8s.io/api/core/v1.ServiceAccountTokenProjection"}, + } +} + +func schema_k8sio_api_core_v1_VolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents the source of a volume to mount. Only one of its members may be specified.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "hostPath": { + SchemaProps: spec.SchemaProps{ + Description: "hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + Ref: ref("k8s.io/api/core/v1.HostPathVolumeSource"), + }, + }, + "emptyDir": { + SchemaProps: spec.SchemaProps{ + Description: "emptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + Ref: ref("k8s.io/api/core/v1.EmptyDirVolumeSource"), + }, + }, + "gcePersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + Ref: ref("k8s.io/api/core/v1.GCEPersistentDiskVolumeSource"), + }, + }, + "awsElasticBlockStore": { + SchemaProps: spec.SchemaProps{ + Description: "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + Ref: ref("k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource"), + }, + }, + "gitRepo": { + SchemaProps: spec.SchemaProps{ + Description: "gitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.", + Ref: ref("k8s.io/api/core/v1.GitRepoVolumeSource"), + }, + }, + "secret": { + SchemaProps: spec.SchemaProps{ + Description: "secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + Ref: ref("k8s.io/api/core/v1.SecretVolumeSource"), + }, + }, + "nfs": { + SchemaProps: spec.SchemaProps{ + Description: "nfs represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + Ref: ref("k8s.io/api/core/v1.NFSVolumeSource"), + }, + }, + "iscsi": { + SchemaProps: spec.SchemaProps{ + Description: "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md", + Ref: ref("k8s.io/api/core/v1.ISCSIVolumeSource"), + }, + }, + "glusterfs": { + SchemaProps: spec.SchemaProps{ + Description: "glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md", + Ref: ref("k8s.io/api/core/v1.GlusterfsVolumeSource"), + }, + }, + "persistentVolumeClaim": { + SchemaProps: spec.SchemaProps{ + Description: "persistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource"), + }, + }, + "rbd": { + SchemaProps: spec.SchemaProps{ + Description: "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md", + Ref: ref("k8s.io/api/core/v1.RBDVolumeSource"), + }, + }, + "flexVolume": { + SchemaProps: spec.SchemaProps{ + Description: "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.", + Ref: ref("k8s.io/api/core/v1.FlexVolumeSource"), + }, + }, + "cinder": { + SchemaProps: spec.SchemaProps{ + Description: "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md", + Ref: ref("k8s.io/api/core/v1.CinderVolumeSource"), + }, + }, + "cephfs": { + SchemaProps: spec.SchemaProps{ + Description: "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.CephFSVolumeSource"), + }, + }, + "flocker": { + SchemaProps: spec.SchemaProps{ + Description: "flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running", + Ref: ref("k8s.io/api/core/v1.FlockerVolumeSource"), + }, + }, + "downwardAPI": { + SchemaProps: spec.SchemaProps{ + Description: "downwardAPI represents downward API about the pod that should populate this volume", + Ref: ref("k8s.io/api/core/v1.DownwardAPIVolumeSource"), + }, + }, + "fc": { + SchemaProps: spec.SchemaProps{ + Description: "fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + Ref: ref("k8s.io/api/core/v1.FCVolumeSource"), + }, + }, + "azureFile": { + SchemaProps: spec.SchemaProps{ + Description: "azureFile represents an Azure File Service mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureFileVolumeSource"), + }, + }, + "configMap": { + SchemaProps: spec.SchemaProps{ + Description: "configMap represents a configMap that should populate this volume", + Ref: ref("k8s.io/api/core/v1.ConfigMapVolumeSource"), + }, + }, + "vsphereVolume": { + SchemaProps: spec.SchemaProps{ + Description: "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"), + }, + }, + "quobyte": { + SchemaProps: spec.SchemaProps{ + Description: "quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + Ref: ref("k8s.io/api/core/v1.QuobyteVolumeSource"), + }, + }, + "azureDisk": { + SchemaProps: spec.SchemaProps{ + Description: "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + Ref: ref("k8s.io/api/core/v1.AzureDiskVolumeSource"), + }, + }, + "photonPersistentDisk": { + SchemaProps: spec.SchemaProps{ + Description: "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource"), + }, + }, + "projected": { + SchemaProps: spec.SchemaProps{ + Description: "projected items for all in one resources secrets, configmaps, and downward API", + Ref: ref("k8s.io/api/core/v1.ProjectedVolumeSource"), + }, + }, + "portworxVolume": { + SchemaProps: spec.SchemaProps{ + Description: "portworxVolume represents a portworx volume attached and mounted on kubelets host machine", + Ref: ref("k8s.io/api/core/v1.PortworxVolumeSource"), + }, + }, + "scaleIO": { + SchemaProps: spec.SchemaProps{ + Description: "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.ScaleIOVolumeSource"), + }, + }, + "storageos": { + SchemaProps: spec.SchemaProps{ + Description: "storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.", + Ref: ref("k8s.io/api/core/v1.StorageOSVolumeSource"), + }, + }, + "csi": { + SchemaProps: spec.SchemaProps{ + Description: "csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).", + Ref: ref("k8s.io/api/core/v1.CSIVolumeSource"), + }, + }, + "ephemeral": { + SchemaProps: spec.SchemaProps{ + Description: "ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed.\n\nUse this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity\n tracking are needed,\nc) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through\n a PersistentVolumeClaim (see EphemeralVolumeSource for more\n information on the connection between this volume type\n and PersistentVolumeClaim).\n\nUse PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod.\n\nUse CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information.\n\nA pod can use both types of ephemeral volumes and persistent volumes at the same time.", + Ref: ref("k8s.io/api/core/v1.EphemeralVolumeSource"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource", "k8s.io/api/core/v1.AzureDiskVolumeSource", "k8s.io/api/core/v1.AzureFileVolumeSource", "k8s.io/api/core/v1.CSIVolumeSource", "k8s.io/api/core/v1.CephFSVolumeSource", "k8s.io/api/core/v1.CinderVolumeSource", "k8s.io/api/core/v1.ConfigMapVolumeSource", "k8s.io/api/core/v1.DownwardAPIVolumeSource", "k8s.io/api/core/v1.EmptyDirVolumeSource", "k8s.io/api/core/v1.EphemeralVolumeSource", "k8s.io/api/core/v1.FCVolumeSource", "k8s.io/api/core/v1.FlexVolumeSource", "k8s.io/api/core/v1.FlockerVolumeSource", "k8s.io/api/core/v1.GCEPersistentDiskVolumeSource", "k8s.io/api/core/v1.GitRepoVolumeSource", "k8s.io/api/core/v1.GlusterfsVolumeSource", "k8s.io/api/core/v1.HostPathVolumeSource", "k8s.io/api/core/v1.ISCSIVolumeSource", "k8s.io/api/core/v1.NFSVolumeSource", "k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource", "k8s.io/api/core/v1.PhotonPersistentDiskVolumeSource", "k8s.io/api/core/v1.PortworxVolumeSource", "k8s.io/api/core/v1.ProjectedVolumeSource", "k8s.io/api/core/v1.QuobyteVolumeSource", "k8s.io/api/core/v1.RBDVolumeSource", "k8s.io/api/core/v1.ScaleIOVolumeSource", "k8s.io/api/core/v1.SecretVolumeSource", "k8s.io/api/core/v1.StorageOSVolumeSource", "k8s.io/api/core/v1.VsphereVirtualDiskVolumeSource"}, + } +} + +func schema_k8sio_api_core_v1_VsphereVirtualDiskVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Represents a vSphere volume resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumePath": { + SchemaProps: spec.SchemaProps{ + Description: "volumePath is the path that identifies vSphere volume vmdk", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fsType": { + SchemaProps: spec.SchemaProps{ + Description: "fsType is filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + Type: []string{"string"}, + Format: "", + }, + }, + "storagePolicyName": { + SchemaProps: spec.SchemaProps{ + Description: "storagePolicyName is the storage Policy Based Management (SPBM) profile name.", + Type: []string{"string"}, + Format: "", + }, + }, + "storagePolicyID": { + SchemaProps: spec.SchemaProps{ + Description: "storagePolicyID is the storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"volumePath"}, + }, + }, + } +} + +func schema_k8sio_api_core_v1_WeightedPodAffinityTerm(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s)", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "weight": { + SchemaProps: spec.SchemaProps{ + Description: "weight associated with matching the corresponding podAffinityTerm, in the range 1-100.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "podAffinityTerm": { + SchemaProps: spec.SchemaProps{ + Description: "Required. A pod affinity term, associated with the corresponding weight.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.PodAffinityTerm"), + }, + }, + }, + Required: []string{"weight", "podAffinityTerm"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.PodAffinityTerm"}, + } +} + +func schema_k8sio_api_core_v1_WindowsSecurityContextOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "WindowsSecurityContextOptions contain Windows-specific options and credentials.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "gmsaCredentialSpecName": { + SchemaProps: spec.SchemaProps{ + Description: "GMSACredentialSpecName is the name of the GMSA credential spec to use.", + Type: []string{"string"}, + Format: "", + }, + }, + "gmsaCredentialSpec": { + SchemaProps: spec.SchemaProps{ + Description: "GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field.", + Type: []string{"string"}, + Format: "", + }, + }, + "runAsUserName": { + SchemaProps: spec.SchemaProps{ + Description: "The UserName in Windows to run the entrypoint of the container process. Defaults to the user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + Type: []string{"string"}, + Format: "", + }, + }, + "hostProcess": { + SchemaProps: spec.SchemaProps{ + Description: "HostProcess determines if a container should be run as a 'Host Process' container. This field is alpha-level and will only be honored by components that enable the WindowsHostProcessContainers feature flag. Setting this field without the feature flag will result in errors when validating the Pod. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_apimachinery_pkg_api_resource_Quantity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.EmbedOpenAPIDefinitionIntoV2Extension(common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.", + OneOf: common.GenerateOpenAPIV3OneOfSchema(resource.Quantity{}.OpenAPIV3OneOfTypes()), + Format: resource.Quantity{}.OpenAPISchemaFormat(), + }, + }, + }, common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.", + Type: resource.Quantity{}.OpenAPISchemaType(), + Format: resource.Quantity{}.OpenAPISchemaFormat(), + }, + }, + }) +} + +func schema_apimachinery_pkg_api_resource_int64Amount(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "int64Amount represents a fixed precision numerator and arbitrary scale exponent. It is faster than operations on inf.Dec for values that can be represented as int64.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "scale": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"value", "scale"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIGroup contains the name, the supported versions, and the preferred version of a group.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the name of the group.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "versions": { + SchemaProps: spec.SchemaProps{ + Description: "versions are the versions supported in this group.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery"), + }, + }, + }, + }, + }, + "preferredVersion": { + SchemaProps: spec.SchemaProps{ + Description: "preferredVersion is the version preferred by the API server, which probably is the storage version.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery"), + }, + }, + "serverAddressByClientCIDRs": { + SchemaProps: spec.SchemaProps{ + Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR"), + }, + }, + }, + }, + }, + }, + Required: []string{"name", "versions"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery", "k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR"}, + } +} + +func schema_pkg_apis_meta_v1_APIGroupList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "groups": { + SchemaProps: spec.SchemaProps{ + Description: "groups is a list of APIGroup.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup"), + }, + }, + }, + }, + }, + }, + Required: []string{"groups"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup"}, + } +} + +func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIResource specifies the name of a resource and whether it is namespaced.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the plural name of the resource.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "singularName": { + SchemaProps: spec.SchemaProps{ + Description: "singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. The singularName is more correct for reporting status on a single item and both singular and plural are allowed from the kubectl CLI interface.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "namespaced": { + SchemaProps: spec.SchemaProps{ + Description: "namespaced indicates if a resource is namespaced or not.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Description: "group is the preferred group of the resource. Empty implies the group of the containing resource list. For subresources, this may have a different value, for example: Scale\".", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Description: "version is the preferred version of the resource. Empty implies the version of the containing resource list For subresources, this may have a different value, for example: v1 (while inside a v1beta1 version of the core resource's group)\".", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "verbs": { + SchemaProps: spec.SchemaProps{ + Description: "verbs is a list of supported kube verbs (this includes get, list, watch, create, update, patch, delete, deletecollection, and proxy)", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "shortNames": { + SchemaProps: spec.SchemaProps{ + Description: "shortNames is a list of suggested short names of the resource.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "categories": { + SchemaProps: spec.SchemaProps{ + Description: "categories is a list of the grouped resources this resource belongs to (e.g. 'all')", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "storageVersionHash": { + SchemaProps: spec.SchemaProps{ + Description: "The hash value of the storage version, the version this resource is converted to when written to the data store. Value must be treated as opaque by clients. Only equality comparison on the value is valid. This is an alpha feature and may change or be removed in the future. The field is populated by the apiserver only if the StorageVersionHash feature gate is enabled. This field will remain optional even if it graduates.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "singularName", "namespaced", "kind", "verbs"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_APIResourceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIResourceList is a list of APIResource, it is used to expose the name of the resources supported in a specific group and version, and if the resource is namespaced.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "groupVersion": { + SchemaProps: spec.SchemaProps{ + Description: "groupVersion is the group and version this APIResourceList is for.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "resources contains the name of the resources and if they are namespaced.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.APIResource"), + }, + }, + }, + }, + }, + }, + Required: []string{"groupVersion", "resources"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.APIResource"}, + } +} + +func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "versions": { + SchemaProps: spec.SchemaProps{ + Description: "versions are the api versions that are available.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "serverAddressByClientCIDRs": { + SchemaProps: spec.SchemaProps{ + Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR"), + }, + }, + }, + }, + }, + }, + Required: []string{"versions", "serverAddressByClientCIDRs"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR"}, + } +} + +func schema_pkg_apis_meta_v1_ApplyOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ApplyOptions may be provided when applying an API object. FieldManager is required for apply requests. ApplyOptions is equivalent to PatchOptions. It is provided as a convenience with documentation that speaks specifically to how the options fields relate to apply.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "force": { + SchemaProps: spec.SchemaProps{ + Description: "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"force", "fieldManager"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Condition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Condition contains details for one aspect of the current state of this API Resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type of condition in CamelCase or in foo.example.com/CamelCase.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "observedGeneration": { + SchemaProps: spec.SchemaProps{ + Description: "observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "message is a human readable message indicating details about the transition. This may be an empty string.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status", "lastTransitionTime", "reason", "message"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_pkg_apis_meta_v1_CreateOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "CreateOptions may be provided when creating an API object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_DeleteOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DeleteOptions may be provided when deleting an API object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "gracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "preconditions": { + SchemaProps: spec.SchemaProps{ + Description: "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Preconditions"), + }, + }, + "orphanDependents": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "propagationPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Preconditions"}, + } +} + +func schema_pkg_apis_meta_v1_Duration(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Duration is a wrapper around time.Duration which supports correct marshaling to YAML and JSON. In particular, it marshals into strings, which can be used as map keys in json.", + Type: v1.Duration{}.OpenAPISchemaType(), + Format: v1.Duration{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_FieldsV1(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.\n\nEach key is either a '.' representing the field itself, and will always map to an empty set, or a string representing a sub-field or item. The string will follow one of these four formats: 'f:', where is the name of a field in a struct, or key in a map 'v:', where is the exact json formatted value of a list item 'i:', where is position of a item in a list 'k:', where is a map of a list item's key fields to their unique values If a key maps to an empty Fields value, the field that key represents is part of the set.\n\nThe exact format is defined in sigs.k8s.io/structured-merge-diff", + Type: []string{"object"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GetOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GetOptions is the standard query options to the standard REST get call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupKind specifies a Group and a Kind, but does not force a version. This is useful for identifying concepts during lookup stages without having partially valid types", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "kind"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupResource specifies a Group and a Resource, but does not force a version. This is useful for identifying concepts during lookup stages without having partially valid types", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "resource"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersion(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersion contains the \"group\" and the \"version\", which uniquely identifies the API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersion contains the \"group/version\" and \"version\" string of a version. It is made a struct to keep extensibility.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "groupVersion": { + SchemaProps: spec.SchemaProps{ + Description: "groupVersion specifies the API group and version in the form \"group/version\"", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Description: "version specifies the version in the form of \"version\". This is to save the clients the trouble of splitting the GroupVersion.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"groupVersion", "version"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version", "kind"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version", "resource"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_InternalEvent(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InternalEvent makes watch.Event versioned", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "Object": { + SchemaProps: spec.SchemaProps{ + Description: "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Bookmark: the object (instance of a type being watched) where\n only ResourceVersion field is set. On successful restart of watch from a\n bookmark resourceVersion, client is guaranteed to not get repeat event\n nor miss any events.\n * If Type is Error: *api.Status is recommended; other types may make sense\n depending on context.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.Object"), + }, + }, + }, + Required: []string{"Type", "Object"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.Object"}, + } +} + +func schema_pkg_apis_meta_v1_LabelSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchLabels": { + SchemaProps: spec.SchemaProps{ + Description: "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "matchExpressions": { + SchemaProps: spec.SchemaProps{ + Description: "matchExpressions is a list of label selector requirements. The requirements are ANDed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement"), + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement"}, + } +} + +func schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "key", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "key is the label key that the selector applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Description: "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_List(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "List holds a list of objects, which may not be known by the server.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + +func schema_pkg_apis_meta_v1_ListMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "selfLink": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", + Type: []string{"string"}, + Format: "", + }, + }, + "continue": { + SchemaProps: spec.SchemaProps{ + Description: "continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message.", + Type: []string{"string"}, + Format: "", + }, + }, + "remainingItemCount": { + SchemaProps: spec.SchemaProps{ + Description: "remainingItemCount is the number of subsequent items in the list which are not included in this list response. If the list request contained label or field selectors, then the number of remaining items is unknown and the field will be left unset and omitted during serialization. If the list is complete (either because it is not chunking or because this is the last chunk), then there are no more remaining items and this field will be left unset and omitted during serialization. Servers older than v1.15 do not set this field. The intended use of the remainingItemCount is *estimating* the size of a collection. Clients should not rely on the remainingItemCount to be set or to be exact.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ListOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ListOptions is the query options to a standard REST list call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + Type: []string{"string"}, + Format: "", + }, + }, + "watch": { + SchemaProps: spec.SchemaProps{ + Description: "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "allowWatchBookmarks": { + SchemaProps: spec.SchemaProps{ + Description: "allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersionMatch": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + "timeoutSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "limit": { + SchemaProps: spec.SchemaProps{ + Description: "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "continue": { + SchemaProps: spec.SchemaProps{ + Description: "The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.", + Type: []string{"string"}, + Format: "", + }, + }, + "sendInitialEvents": { + SchemaProps: spec.SchemaProps{ + Description: "`sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic \"Bookmark\" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `\"k8s.io/initial-events-end\": \"true\"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched.\n\nWhen `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan\n is interpreted as \"data at least as new as the provided `resourceVersion`\"\n and the bookmark event is send when the state is synced\n to a `resourceVersion` at least as fresh as the one provided by the ListOptions.\n If `resourceVersion` is unset, this is interpreted as \"consistent read\" and the\n bookmark event is send when the state is synced at least to the moment\n when request started being processed.\n- `resourceVersionMatch` set to any other value or unset\n Invalid error is returned.\n\nDefaults to true if `resourceVersion=\"\"` or `resourceVersion=\"0\"` (for backward compatibility reasons) and to false otherwise.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "manager": { + SchemaProps: spec.SchemaProps{ + Description: "Manager is an identifier of the workflow managing these fields.", + Type: []string{"string"}, + Format: "", + }, + }, + "operation": { + SchemaProps: spec.SchemaProps{ + Description: "Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the version of this resource that this field set applies to. The format is \"group/version\" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.", + Type: []string{"string"}, + Format: "", + }, + }, + "time": { + SchemaProps: spec.SchemaProps{ + Description: "Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "fieldsType": { + SchemaProps: spec.SchemaProps{ + Description: "FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: \"FieldsV1\"", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldsV1": { + SchemaProps: spec.SchemaProps{ + Description: "FieldsV1 holds the first JSON version format as described in the \"FieldsV1\" type.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1"), + }, + }, + "subresource": { + SchemaProps: spec.SchemaProps{ + Description: "Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_pkg_apis_meta_v1_MicroTime(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MicroTime is version of Time with microsecond level precision.", + Type: v1.MicroTime{}.OpenAPISchemaType(), + Format: v1.MicroTime{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names", + Type: []string{"string"}, + Format: "", + }, + }, + "generateName": { + SchemaProps: spec.SchemaProps{ + Description: "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.\n\nIf this field is specified and the generated name exists, the server will return a 409.\n\nApplied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.\n\nMust be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces", + Type: []string{"string"}, + Format: "", + }, + }, + "selfLink": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.\n\nPopulated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", + Type: []string{"string"}, + Format: "", + }, + }, + "generation": { + SchemaProps: spec.SchemaProps{ + Description: "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "creationTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "deletionTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "deletionGracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "labels": { + SchemaProps: spec.SchemaProps{ + Description: "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "annotations": { + SchemaProps: spec.SchemaProps{ + Description: "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "ownerReferences": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "uid", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference"), + }, + }, + }, + }, + }, + "finalizers": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "managedFields": { + SchemaProps: spec.SchemaProps{ + Description: "ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like \"ci-cd\". The set of fields is always in the version that the workflow used when modifying the object.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ManagedFieldsEntry"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ManagedFieldsEntry", "k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_pkg_apis_meta_v1_OwnerReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "API version of the referent.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "controller": { + SchemaProps: spec.SchemaProps{ + Description: "If true, this reference points to the managing controller.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "blockOwnerDeletion": { + SchemaProps: spec.SchemaProps{ + Description: "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. See https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion for how the garbage collector interacts with this field and enforces the foreground deletion. Defaults to false. To set this field, a user needs \"delete\" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"apiVersion", "kind", "name", "uid"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_PartialObjectMetadata(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients to get access to a particular ObjectMeta schema without knowing the details of the version.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PartialObjectMetadataList contains a list of objects containing only their metadata", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items contains each of the included items.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadata"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadata"}, + } +} + +func schema_pkg_apis_meta_v1_Patch(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.", + Type: []string{"object"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_PatchOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PatchOptions may be provided when patching an API object. PatchOptions is meant to be a superset of UpdateOptions.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "force": { + SchemaProps: spec.SchemaProps{ + Description: "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Preconditions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the target UID.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the target ResourceVersion", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_RootPaths(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RootPaths lists the paths available at root. For example: \"/healthz\", \"/apis\".", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "paths": { + SchemaProps: spec.SchemaProps{ + Description: "paths are the paths available at root.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"paths"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "clientCIDR": { + SchemaProps: spec.SchemaProps{ + Description: "The CIDR with which clients can match their IP to figure out the server address that they should use.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "serverAddress": { + SchemaProps: spec.SchemaProps{ + Description: "Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"clientCIDR", "serverAddress"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Status is a return value for calls that don't return other objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human-readable description of the status of this operation.", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.", + Type: []string{"string"}, + Format: "", + }, + }, + "details": { + SchemaProps: spec.SchemaProps{ + Description: "Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails"), + }, + }, + "code": { + SchemaProps: spec.SchemaProps{ + Description: "Suggested HTTP return code for this status, 0 if not set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails"}, + } +} + +func schema_pkg_apis_meta_v1_StatusCause(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "A machine-readable description of the cause of the error. If this value is empty there is no information available.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human-readable description of the cause of the error. This field may be presented as-is to a reader.", + Type: []string{"string"}, + Format: "", + }, + }, + "field": { + SchemaProps: spec.SchemaProps{ + Description: "The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.\n\nExamples:\n \"name\" - the field \"name\" on the current resource\n \"items[0].name\" - the field \"name\" on the first array entry in \"items\"", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_StatusDetails(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).", + Type: []string{"string"}, + Format: "", + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Description: "The group attribute of the resource associated with the status StatusReason.", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Type: []string{"string"}, + Format: "", + }, + }, + "causes": { + SchemaProps: spec.SchemaProps{ + Description: "The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.StatusCause"), + }, + }, + }, + }, + }, + "retryAfterSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.StatusCause"}, + } +} + +func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Table is a tabular representation of a set of API resources. The server transforms the object into a set of preferred columns for quickly reviewing the objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "columnDefinitions": { + SchemaProps: spec.SchemaProps{ + Description: "columnDefinitions describes each column in the returned items array. The number of cells per row will always match the number of column definitions.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.TableColumnDefinition"), + }, + }, + }, + }, + }, + "rows": { + SchemaProps: spec.SchemaProps{ + Description: "rows is the list of items in the table.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.TableRow"), + }, + }, + }, + }, + }, + }, + Required: []string{"columnDefinitions", "rows"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "k8s.io/apimachinery/pkg/apis/meta/v1.TableColumnDefinition", "k8s.io/apimachinery/pkg/apis/meta/v1.TableRow"}, + } +} + +func schema_pkg_apis_meta_v1_TableColumnDefinition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableColumnDefinition contains information about a column returned in the Table.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is a human readable name for the column.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type is an OpenAPI type definition for this column, such as number, integer, string, or array. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "format": { + SchemaProps: spec.SchemaProps{ + Description: "format is an optional OpenAPI type modifier for this column. A format modifies the type and imposes additional rules, like date or time formatting for a string. The 'name' format is applied to the primary identifier column which has type 'string' to assist in clients identifying column is the resource name. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "description is a human readable description of this column.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "priority": { + SchemaProps: spec.SchemaProps{ + Description: "priority is an integer defining the relative importance of this column compared to others. Lower numbers are considered higher priority. Columns that may be omitted in limited space scenarios should be given a higher priority.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"name", "type", "format", "description", "priority"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TableOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableOptions are used when a Table is requested by the caller.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "includeObject": { + SchemaProps: spec.SchemaProps{ + Description: "includeObject decides whether to include each object along with its columnar information. Specifying \"None\" will return no object, specifying \"Object\" will return the full object contents, and specifying \"Metadata\" (the default) will return the object's metadata in the PartialObjectMetadata kind in version v1beta1 of the meta.k8s.io API group.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TableRow(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableRow is an individual row in a table.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "cells": { + SchemaProps: spec.SchemaProps{ + Description: "cells will be as wide as the column definitions array and may contain strings, numbers (float64 or int64), booleans, simple maps, lists, or null. See the type field of the column definition for a more detailed description.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + "conditions": { + SchemaProps: spec.SchemaProps{ + Description: "conditions describe additional status of a row that are relevant for a human user. These conditions apply to the row, not to the object, and will be specific to table output. The only defined condition type is 'Completed', for a row that indicates a resource that has run to completion and can be given less visual priority.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.TableRowCondition"), + }, + }, + }, + }, + }, + "object": { + SchemaProps: spec.SchemaProps{ + Description: "This field contains the requested additional information about each object based on the includeObject policy when requesting the Table. If \"None\", this field is empty, if \"Object\" this will be the default serialization of the object for the current API version, and if \"Metadata\" (the default) will contain the object metadata. Check the returned kind and apiVersion of the object before parsing. The media type of the object will always match the enclosing list - if this as a JSON table, these will be JSON encoded objects.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + Required: []string{"cells"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.TableRowCondition", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + +func schema_pkg_apis_meta_v1_TableRowCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableRowCondition allows a row to be marked with additional information.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of row condition. The only defined value is 'Completed' indicating that the object this row represents has reached a completed state and may be given less visual priority than other rows. Clients are not required to honor any conditions but should be consistent where possible about handling the conditions.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) machine readable reason for the condition's last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Human readable message indicating details about last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Time(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.", + Type: v1.Time{}.OpenAPISchemaType(), + Format: v1.Time{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Timestamp(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Timestamp is a struct that is equivalent to Time, but intended for protobuf marshalling/unmarshalling. It is generated into a serialization that matches Time. Do not use in Go structs.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "seconds": { + SchemaProps: spec.SchemaProps{ + Description: "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "nanos": { + SchemaProps: spec.SchemaProps{ + Description: "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive. This field may be limited in precision depending on context.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"seconds", "nanos"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TypeMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TypeMeta describes an individual object in an API response or request with strings representing the type of the object and its API schema version. Structures that are versioned or persisted should inline TypeMeta.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_UpdateOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "UpdateOptions may be provided when updating an API object. All fields in UpdateOptions should also be present in PatchOptions.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_WatchEvent(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Event represents a single event to a watched resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "object": { + SchemaProps: spec.SchemaProps{ + Description: "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Error: *Status is recommended; other types may make sense\n depending on context.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + Required: []string{"type", "object"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.Object `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// External package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// On the wire, the JSON will look something like this:\n\n\t{\n\t\t\"kind\":\"MyAPIObject\",\n\t\t\"apiVersion\":\"v1\",\n\t\t\"myPlugin\": {\n\t\t\t\"kind\":\"PluginA\",\n\t\t\t\"aOption\":\"foo\",\n\t\t},\n\t}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)", + Type: []string{"object"}, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, like this:\n\n\ttype MyAwesomeAPIObject struct {\n\t runtime.TypeMeta `json:\",inline\"`\n\t ... // other fields\n\t}\n\nfunc (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind\n\nTypeMeta is provided here for convenience. You may use it directly from this package or define your own with the same fields.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_Unknown(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Unknown allows api objects with unknown types to be passed-through. This can be used to deal with the API objects from a plug-in. Unknown objects still have functioning TypeMeta features-- kind, version, etc. metadata and field mutatation.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "ContentEncoding": { + SchemaProps: spec.SchemaProps{ + Description: "ContentEncoding is encoding used to encode 'Raw' data. Unspecified means no encoding.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ContentType": { + SchemaProps: spec.SchemaProps{ + Description: "ContentType is serialization method used to serialize 'Raw'. Unspecified means ContentTypeJSON.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"ContentEncoding", "ContentType"}, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_version_Info(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Info contains versioning information. how we'll want to distribute that information.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "major": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "minor": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "gitVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "gitCommit": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "gitTreeState": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "buildDate": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "goVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "compiler": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "platform": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"major", "minor", "gitVersion", "gitCommit", "gitTreeState", "buildDate", "goVersion", "compiler", "platform"}, + }, + }, + } +} diff --git a/apinetlet/main.go b/cmd/apinetlet/main.go similarity index 87% rename from apinetlet/main.go rename to cmd/apinetlet/main.go index 7c697c43..f1cce32b 100644 --- a/apinetlet/main.go +++ b/cmd/apinetlet/main.go @@ -22,9 +22,10 @@ import ( "fmt" "os" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" apinetletconfig "github.com/onmetal/onmetal-api-net/apinetlet/client/config" "github.com/onmetal/onmetal-api-net/apinetlet/controllers" + "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1" networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1" "github.com/onmetal/onmetal-api/utils/client/config" @@ -154,18 +155,36 @@ func main() { os.Exit(1) } + apiNetIface, err := onmetalapinet.NewForConfig(apiNetCfg) + if err != nil { + setupLog.Error(err, "unable to create api net interface") + os.Exit(1) + } + if err := mgr.Add(apiNetCluster); err != nil { setupLog.Error(err, "unable to add cluster", "cluster", "APINet") os.Exit(1) } - if err = (&controllers.VirtualIPReconciler{ + if err = (&controllers.LoadBalancerReconciler{ Client: mgr.GetClient(), APINetClient: apiNetCluster.GetClient(), + APINetInterface: apiNetIface, APINetNamespace: apiNetNamespace, WatchFilterValue: watchFilterValue, - }).SetupWithManager(mgr, apiNetCluster); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "VirtualIP") + }).SetupWithManager(mgr, apiNetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "LoadBalancer") + os.Exit(1) + } + + if err = (&controllers.NATGatewayReconciler{ + Client: mgr.GetClient(), + APINetClient: apiNetCluster.GetClient(), + APINetInterface: apiNetIface, + APINetNamespace: apiNetNamespace, + WatchFilterValue: watchFilterValue, + }).SetupWithManager(mgr, apiNetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "NATGateway") os.Exit(1) } @@ -174,31 +193,31 @@ func main() { APINetClient: apiNetCluster.GetClient(), APINetNamespace: apiNetNamespace, WatchFilterValue: watchFilterValue, - }).SetupWithManager(mgr, apiNetCluster); err != nil { + }).SetupWithManager(mgr, apiNetCluster.GetCache()); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Network") os.Exit(1) } - if err = (&controllers.NATGatewayReconciler{ + if err = (&controllers.NetworkInterfaceReconciler{ Client: mgr.GetClient(), APINetClient: apiNetCluster.GetClient(), APINetNamespace: apiNetNamespace, WatchFilterValue: watchFilterValue, - }).SetupWithManager(mgr, apiNetCluster); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "NATGateway") + }).SetupWithManager(mgr, apiNetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "NetworkInterface") os.Exit(1) } - if err = (&controllers.LoadBalancerReconciler{ + if err = (&controllers.VirtualIPReconciler{ Client: mgr.GetClient(), APINetClient: apiNetCluster.GetClient(), + APINetInterface: apiNetIface, APINetNamespace: apiNetNamespace, WatchFilterValue: watchFilterValue, - }).SetupWithManager(mgr, apiNetCluster); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "LoadBalancer") + }).SetupWithManager(mgr, apiNetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "VirtualIP") os.Exit(1) } - //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { setupLog.Error(err, "unable to set up health check") diff --git a/cmd/apiserver/main.go b/cmd/apiserver/main.go new file mode 100644 index 00000000..7a3e9870 --- /dev/null +++ b/cmd/apiserver/main.go @@ -0,0 +1,31 @@ +// Copyright 2023 OnMetal 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 main + +import ( + "os" + + "github.com/onmetal/onmetal-api-net/internal/app/apiserver" + "k8s.io/apiserver/pkg/server" + "k8s.io/component-base/cli" +) + +func main() { + ctx := server.SetupSignalContext() + options := apiserver.NewOnmetalAPINetServerOptions() + cmd := apiserver.NewCommandStartOnmetalAPINetServer(ctx, options) + code := cli.Run(cmd) + os.Exit(code) +} diff --git a/onmetal-api-net/main.go b/cmd/controller-manager/main.go similarity index 62% rename from onmetal-api-net/main.go rename to cmd/controller-manager/main.go index 544e6d38..15e34bbc 100644 --- a/onmetal-api-net/main.go +++ b/cmd/controller-manager/main.go @@ -18,15 +18,16 @@ package main import ( goflag "flag" - "net/netip" "os" "github.com/onmetal/controller-utils/configutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - netflag "github.com/onmetal/onmetal-api-net/flag" - "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers" - onmetalapinet "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/onmetal-api-net" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/controllers" + onmetalapinet "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/onmetal-api-net" + "github.com/onmetal/onmetal-api-net/internal/controllers/scheduler" + "github.com/onmetal/onmetal-api-net/utils/expectations" flag "github.com/spf13/pflag" + "k8s.io/utils/lru" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. @@ -59,21 +60,12 @@ func main() { var enableLeaderElection bool var probeAddr string - var prefixes []netip.Prefix - - var minVNI, maxVNI int32 - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") - netflag.IPPrefixesVar(&prefixes, "prefixes", nil, "IP Prefixes to allocate from.") - - flag.Int32Var(&minVNI, "min-vni", controllers.DefaultMinVNI, "Default minimum vni to allocate.") - flag.Int32Var(&maxVNI, "max-vni", controllers.DefaultMaxVNI, "Default maximum vni to allocate.") - opts := zap.Options{ Development: true, } @@ -102,41 +94,79 @@ func main() { os.Exit(1) } - initialAvailableIPs, err := netflag.IPSetFromPrefixes(prefixes) - if err != nil { - setupLog.Error(err, "invalid ipv4 prefixes") + if err = (&controllers.CertificateApprovalReconciler{ + Client: mgr.GetClient(), + Recognizers: onmetalapinet.Recognizers, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "CertificateApproval") + os.Exit(1) + } + + if err = (&controllers.DaemonSetReconciler{ + Client: mgr.GetClient(), + Expectations: expectations.New(), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "DaemonSet") + os.Exit(1) + } + + if err = (&controllers.IPAddressGCReconciler{ + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + AbsenceCache: lru.New(500), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "DaemonSet") os.Exit(1) } - if err = (&controllers.PublicIPReconciler{ - EventRecorder: mgr.GetEventRecorderFor("publicip"), - Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - InitialAvailableIPs: initialAvailableIPs, + if err = (&controllers.LoadBalancerReconciler{ + Client: mgr.GetClient(), }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "PublicIP") + setupLog.Error(err, "unable to create controller", "controller", "LoadBalancer") os.Exit(1) } - if err = (&controllers.NetworkReconciler{ - EventRecorder: mgr.GetEventRecorderFor("network"), + if err = (&controllers.NATGatewayReconciler{ Client: mgr.GetClient(), - APIReader: mgr.GetAPIReader(), - MinVNI: minVNI, - MaxVNI: maxVNI, + EventRecorder: mgr.GetEventRecorderFor("natgateways"), }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "PublicIP") + setupLog.Error(err, "unable to create controller", "controller", "NATGateway") os.Exit(1) } - if err = (&controllers.CertificateApprovalReconciler{ - Client: mgr.GetClient(), - Recognizers: onmetalapinet.Recognizers, + if err = (&controllers.NATGatewayAutoscalerReconciler{ + Client: mgr.GetClient(), }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "CertificateApproval") + setupLog.Error(err, "unable to create controller", "controller", "NATGatewayAutoscaler") + os.Exit(1) + } + + if err = (&controllers.NetworkIDGCReconciler{ + Client: mgr.GetClient(), + APIReader: mgr.GetAPIReader(), + AbsenceCache: lru.New(500), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "NetworkIDGC") + os.Exit(1) + } + + schedulerCache := scheduler.NewCache( + mgr.GetLogger().WithName("scheduler").WithName("cache"), + scheduler.DefaultCacheStrategy, + ) + if err = mgr.Add(schedulerCache); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "SchedulerCache") + os.Exit(1) + } + + if err = (&controllers.SchedulerReconciler{ + Client: mgr.GetClient(), + EventRecorder: mgr.GetEventRecorderFor("scheduler"), + Cache: schedulerCache, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Scheduler") os.Exit(1) } - //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { setupLog.Error(err, "unable to set up health check") diff --git a/metalnetlet/main.go b/cmd/metalnetlet/main.go similarity index 75% rename from metalnetlet/main.go rename to cmd/metalnetlet/main.go index d31f204a..4511a70e 100644 --- a/metalnetlet/main.go +++ b/cmd/metalnetlet/main.go @@ -23,11 +23,12 @@ import ( "github.com/onmetal/controller-utils/configutils" metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" metalnetletconfig "github.com/onmetal/onmetal-api-net/metalnetlet/client/config" "github.com/onmetal/onmetal-api-net/metalnetlet/controllers" "github.com/onmetal/onmetal-api/utils/client/config" flag "github.com/spf13/pflag" + corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/cluster" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) @@ -66,6 +67,7 @@ func main() { var configOptions config.GetConfigOptions var metalnetKubeconfig string + var metalnetNamespace string flag.StringVar(&name, "name", "", "The name of the partition the metalnetlet represents (required).") flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") @@ -76,6 +78,7 @@ func main() { configOptions.BindFlags(flag.CommandLine) flag.StringVar(&metalnetKubeconfig, "metalnet-kubeconfig", "", "Metalnet kubeconfig to use.") + flag.StringVar(&metalnetNamespace, "metalnet-namespace", corev1.NamespaceDefault, "Metalnet namespace to use.") opts := zap.Options{ Development: true, @@ -137,15 +140,44 @@ func main() { os.Exit(1) } + if err := (&controllers.InstanceReconciler{ + Client: mgr.GetClient(), + MetalnetClient: metalnetCluster.GetClient(), + PartitionName: name, + MetalnetNamespace: metalnetNamespace, + }).SetupWithManager(mgr, metalnetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Instance") + os.Exit(1) + } + + if err := (&controllers.MetalnetNodeReconciler{ + Client: mgr.GetClient(), + MetalnetClient: metalnetCluster.GetClient(), + PartitionName: name, + }).SetupWithManager(mgr, metalnetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "MetalnetNode") + os.Exit(1) + } + if err := (&controllers.NetworkReconciler{ - Client: mgr.GetClient(), - MetalnetCluster: metalnetCluster, - Name: name, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Networking") + Client: mgr.GetClient(), + MetalnetClient: metalnetCluster.GetClient(), + PartitionName: name, + MetalnetNamespace: metalnetNamespace, + }).SetupWithManager(mgr, metalnetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Network") + os.Exit(1) + } + + if err = (&controllers.NetworkInterfaceReconciler{ + Client: mgr.GetClient(), + MetalnetClient: metalnetCluster.GetClient(), + PartitionName: name, + MetalnetNamespace: metalnetNamespace, + }).SetupWithManager(mgr, metalnetCluster.GetCache()); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Network") os.Exit(1) } - //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { setupLog.Error(err, "unable to set up health check") diff --git a/config/apinetlet/apinet-rbac/role.yaml b/config/apinetlet/apinet-rbac/role.yaml index 08468236..f0c3e3ce 100644 --- a/config/apinetlet/apinet-rbac/role.yaml +++ b/config/apinetlet/apinet-rbac/role.yaml @@ -1,32 +1,96 @@ +--- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: + creationTimestamp: null namespace: system name: apinet-role rules: - apiGroups: - apinet.api.onmetal.de resources: - - networks + - ips verbs: + - create + - delete + - deletecollection - get - list - patch - update - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancerroutings + verbs: - create - delete - deletecollection + - get + - list + - patch + - update + - watch - apiGroups: - - apinet.api.onmetal.de + - core.apinet.api.onmetal.de resources: - - publicips + - loadbalancers verbs: + - create + - delete + - deletecollection - get - list - patch - update - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgatewayautoscalers + verbs: - create - delete - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateways + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networks + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch diff --git a/config/apinetlet/rbac/role.yaml b/config/apinetlet/rbac/role.yaml index 9f8b224c..03ecb8a8 100644 --- a/config/apinetlet/rbac/role.yaml +++ b/config/apinetlet/rbac/role.yaml @@ -2,6 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: + creationTimestamp: null name: manager-role rules: - apiGroups: @@ -22,24 +23,6 @@ rules: - patch - update - watch -- apiGroups: - - apinet.api.onmetal.de - resources: - - publicips - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apinet.api.onmetal.de - resources: - - publicips/status - verbs: - - get - apiGroups: - authentication.k8s.io resources: @@ -67,6 +50,14 @@ rules: - certificatesigningrequests/apinetletclient verbs: - create +- apiGroups: + - ipam.api.onmetal.de + resources: + - prefix + verbs: + - get + - list + - watch - apiGroups: - networking.api.onmetal.de resources: @@ -117,6 +108,31 @@ rules: - get - patch - update +- apiGroups: + - networking.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - networkinterfaces/finalizers + verbs: + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - networkinterfaces/status + verbs: + - get + - patch + - update - apiGroups: - networking.api.onmetal.de resources: diff --git a/config/apiserver/apiservice/bases/kustomization.yaml b/config/apiserver/apiservice/bases/kustomization.yaml new file mode 100644 index 00000000..ccaffe8b --- /dev/null +++ b/config/apiserver/apiservice/bases/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - v1alpha1.core.apinet.api.onmetal.de.yaml diff --git a/config/apiserver/apiservice/bases/v1alpha1.core.apinet.api.onmetal.de.yaml b/config/apiserver/apiservice/bases/v1alpha1.core.apinet.api.onmetal.de.yaml new file mode 100644 index 00000000..3a219fb1 --- /dev/null +++ b/config/apiserver/apiservice/bases/v1alpha1.core.apinet.api.onmetal.de.yaml @@ -0,0 +1,12 @@ +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1alpha1.core.apinet.api.onmetal.de +spec: + group: core.apinet.api.onmetal.de + version: v1alpha1 + service: + namespace: system + name: apiserver-service + groupPriorityMinimum: 2000 + versionPriority: 100 diff --git a/config/apiserver/apiservice/kustomization.yaml b/config/apiserver/apiservice/kustomization.yaml new file mode 100644 index 00000000..d0fa9f42 --- /dev/null +++ b/config/apiserver/apiservice/kustomization.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - bases + - service.yaml + +patches: + - path: patch-apiservice.yaml + target: + group: apiregistration.k8s.io + version: v1 + kind: APIService + +configurations: + - kustomizeconfig.yaml diff --git a/config/apiserver/apiservice/kustomizeconfig.yaml b/config/apiserver/apiservice/kustomizeconfig.yaml new file mode 100644 index 00000000..b76bf8b6 --- /dev/null +++ b/config/apiserver/apiservice/kustomizeconfig.yaml @@ -0,0 +1,11 @@ +# This file is for teaching kustomize how to substitute name and namespace reference in APIService +nameReference: + - kind: Service + version: v1 + fieldSpecs: + - kind: APIService + version: v1 + group: apiregistration.k8s.io + path: spec/service/name +varReference: + - path: metadata/annotations \ No newline at end of file diff --git a/config/apiserver/apiservice/patch-apiservice.yaml b/config/apiserver/apiservice/patch-apiservice.yaml new file mode 100644 index 00000000..b9520c16 --- /dev/null +++ b/config/apiserver/apiservice/patch-apiservice.yaml @@ -0,0 +1,8 @@ +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: not-important +spec: + service: + namespace: system + name: apiserver-service diff --git a/config/apiserver/apiservice/service.yaml b/config/apiserver/apiservice/service.yaml new file mode 100644 index 00000000..fc2e4712 --- /dev/null +++ b/config/apiserver/apiservice/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: apiserver-service + namespace: system +spec: + ports: + - port: 443 + targetPort: 8443 + selector: + control-plane: apiserver diff --git a/config/apiserver/certmanager/certificate.yaml b/config/apiserver/certmanager/certificate.yaml new file mode 100644 index 00000000..3e7cca67 --- /dev/null +++ b/config/apiserver/certmanager/certificate.yaml @@ -0,0 +1,24 @@ +# The following manifests contain a self-signed issuer CR and a certificate CR. +# More document can be found at https://docs.cert-manager.io +# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes. +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: apiserver-selfsigned-issuer + namespace: system +spec: + selfSigned: { } +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: apiserver-cert # this name should match the one appeared in kustomizeconfig.yaml + namespace: system +spec: # $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize + dnsNames: + - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc + - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local + issuerRef: + kind: Issuer + name: apiserver-selfsigned-issuer + secretName: apiserver-cert # this secret will not be prefixed, since it's not managed by kustomize diff --git a/config/apiserver/certmanager/kustomization.yaml b/config/apiserver/certmanager/kustomization.yaml new file mode 100644 index 00000000..bebea5a5 --- /dev/null +++ b/config/apiserver/certmanager/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- certificate.yaml + +configurations: +- kustomizeconfig.yaml diff --git a/config/apiserver/certmanager/kustomizeconfig.yaml b/config/apiserver/certmanager/kustomizeconfig.yaml new file mode 100644 index 00000000..90d7c313 --- /dev/null +++ b/config/apiserver/certmanager/kustomizeconfig.yaml @@ -0,0 +1,16 @@ +# This configuration is for teaching kustomize how to update name ref and var substitution +nameReference: +- kind: Issuer + group: cert-manager.io + fieldSpecs: + - kind: Certificate + group: cert-manager.io + path: spec/issuerRef/name + +varReference: +- kind: Certificate + group: cert-manager.io + path: spec/commonName +- kind: Certificate + group: cert-manager.io + path: spec/dnsNames diff --git a/config/apiserver/default/apiserver_certificate_patch.yaml b/config/apiserver/default/apiserver_certificate_patch.yaml new file mode 100644 index 00000000..8b78a73e --- /dev/null +++ b/config/apiserver/default/apiserver_certificate_patch.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: apiserver + namespace: system +spec: + template: + spec: + containers: + - name: apiserver + volumeMounts: + - mountPath: /tmp/k8s-apiserver/serving-certs + name: cert + readOnly: true + args: + - --etcd-servers=http://$(ONMETAL_API_APISERVER_ETCD_SERVICE_NAME):2379 + - --secure-port=8443 + - --audit-log-path=- + - --feature-gates=APIPriorityAndFairness=false + - --audit-log-maxage=0 + - --audit-log-maxbackup=0 + - --tls-cert-file=/tmp/k8s-apiserver/serving-certs/tls.crt + - --tls-private-key-file=/tmp/k8s-apiserver/serving-certs/tls.key + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: apiserver-cert diff --git a/config/apiserver/default/apiservicecainjection_patch.yaml b/config/apiserver/default/apiservicecainjection_patch.yaml new file mode 100644 index 00000000..16137981 --- /dev/null +++ b/config/apiserver/default/apiservicecainjection_patch.yaml @@ -0,0 +1,8 @@ +# This patch adds the injection annotation to the apiservices and +# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1alpha1.core.apinet.api.onmetal.de + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) diff --git a/config/apiserver/default/kustomization.yaml b/config/apiserver/default/kustomization.yaml new file mode 100644 index 00000000..da2be47b --- /dev/null +++ b/config/apiserver/default/kustomization.yaml @@ -0,0 +1,102 @@ +# Adds namespace to all resources. +namespace: onmetal-api-net-system + +# Value of this field is prepended to the +# names of all resources, e.g. a deployment named +# "wordpress" becomes "alices-wordpress". +# Note that it should also match with the prefix (text before '-') of the namespace +# field above. +namePrefix: onmetal-api-net- + +# Labels to add to all resources and selectors. +#commonLabels: +# someName: someValue + +resources: + - ../rbac + - ../etcd + - ../server + - ../apiservice + - ../certmanager + +patchesStrategicMerge: + - apiserver_certificate_patch.yaml + - apiservicecainjection_patch.yaml + +replacements: + - source: + kind: Certificate + group: cert-manager.io + version: v1 + name: apiserver-cert + fieldPath: .metadata.namespace + targets: + - select: + kind: APIService + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 0 + create: true + - source: + kind: Certificate + group: cert-manager.io + version: v1 + name: apiserver-cert + fieldPath: .metadata.name + targets: + - select: + kind: APIService + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 1 + create: true + - source: + kind: Service + version: v1 + name: apiserver-service + fieldPath: .metadata.name + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 0 + create: true + - source: + kind: Service + version: v1 + name: apiserver-service + fieldPath: .metadata.namespace + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 1 + create: true + +vars: # We unfortunately have to use vars here as + # * Env substitution won't work in distroless containers + # * Prefix / Suffix concatenation does not exist yet for replacements + # Monitor the following issue(s) and switch to replacements as soon as implemented: + # * https://github.com/kubernetes-sigs/kustomize/issues/4080 + # * https://github.com/kubernetes-sigs/kustomize/pull/4558 + - name: ONMETAL_API_APISERVER_ETCD_SERVICE_NAME + objref: + kind: Service + name: etcd + apiVersion: v1 diff --git a/config/apiserver/etcd/etcd.yaml b/config/apiserver/etcd/etcd.yaml new file mode 100644 index 00000000..b9803e72 --- /dev/null +++ b/config/apiserver/etcd/etcd.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: etcd + namespace: system + labels: + control-plane: etcd +spec: + selector: + matchLabels: + control-plane: etcd + serviceName: etcd + replicas: 1 + template: + metadata: + annotations: + kubectl.kubernetes.io/default-container: etcd + labels: + control-plane: etcd + spec: + containers: + - command: + - etcd + args: + - -listen-client-urls=http://[::]:2379 + - -advertise-client-urls=http://localhost:2379 + - -data-dir=/etcd-data-dir/default.etcd + image: quay.io/coreos/etcd:v3.5.2 + name: etcd + livenessProbe: + httpGet: + path: /health + port: 2379 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /health + port: 2379 + initialDelaySeconds: 5 + periodSeconds: 10 + # TODO(user): Configure the resources accordingly based on the project requirements. + # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + ports: + - containerPort: 2379 + name: etcd + protocol: TCP + volumeMounts: + - name: etcd-data-dir + mountPath: /etcd-data-dir + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 10m + memory: 64Mi + terminationGracePeriodSeconds: 10 + volumeClaimTemplates: + - metadata: + name: etcd-data-dir + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi diff --git a/config/apiserver/etcd/kustomization.yaml b/config/apiserver/etcd/kustomization.yaml new file mode 100644 index 00000000..bca5c47a --- /dev/null +++ b/config/apiserver/etcd/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - etcd.yaml + - service.yaml diff --git a/config/apiserver/etcd/service.yaml b/config/apiserver/etcd/service.yaml new file mode 100644 index 00000000..7fb03d57 --- /dev/null +++ b/config/apiserver/etcd/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: etcd + namespace: system +spec: + ports: + - port: 2379 + targetPort: 2379 + selector: + control-plane: etcd diff --git a/config/apiserver/etcdless/apiserver_certificate_patch.yaml b/config/apiserver/etcdless/apiserver_certificate_patch.yaml new file mode 100644 index 00000000..aa3f9188 --- /dev/null +++ b/config/apiserver/etcdless/apiserver_certificate_patch.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: apiserver + namespace: system +spec: + template: + spec: + containers: + - name: apiserver + volumeMounts: + - mountPath: /tmp/k8s-apiserver/serving-certs + name: cert + readOnly: true + args: + - --secure-port=8443 + - --audit-log-path=- + - --feature-gates=APIPriorityAndFairness=false + - --audit-log-maxage=0 + - --audit-log-maxbackup=0 + - --tls-cert-file=/tmp/k8s-apiserver/serving-certs/tls.crt + - --tls-private-key-file=/tmp/k8s-apiserver/serving-certs/tls.key + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: apiserver-cert diff --git a/config/apiserver/etcdless/apiservicecainjection_patch.yaml b/config/apiserver/etcdless/apiservicecainjection_patch.yaml new file mode 100644 index 00000000..16137981 --- /dev/null +++ b/config/apiserver/etcdless/apiservicecainjection_patch.yaml @@ -0,0 +1,8 @@ +# This patch adds the injection annotation to the apiservices and +# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1alpha1.core.apinet.api.onmetal.de + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) diff --git a/config/apiserver/etcdless/kustomization.yaml b/config/apiserver/etcdless/kustomization.yaml new file mode 100644 index 00000000..8ab718b4 --- /dev/null +++ b/config/apiserver/etcdless/kustomization.yaml @@ -0,0 +1,89 @@ +# Adds namespace to all resources. +namespace: onmetal-api-net-system + +# Value of this field is prepended to the +# names of all resources, e.g. a deployment named +# "wordpress" becomes "alices-wordpress". +# Note that it should also match with the prefix (text before '-') of the namespace +# field above. +namePrefix: onmetal-api-net + +# Labels to add to all resources and selectors. +#commonLabels: +# someName: someValue + +resources: + - ../rbac + - ../server + - ../apiservice + - ../certmanager + +patchesStrategicMerge: + - apiserver_certificate_patch.yaml + - apiservicecainjection_patch.yaml + +replacements: + - source: + kind: Certificate + group: cert-manager.io + version: v1 + name: apiserver-cert + fieldPath: .metadata.namespace + targets: + - select: + kind: APIService + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 0 + create: true + - source: + kind: Certificate + group: cert-manager.io + version: v1 + name: apiserver-cert + fieldPath: .metadata.name + targets: + - select: + kind: APIService + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 1 + create: true + - source: + kind: Service + version: v1 + name: apiserver-service + fieldPath: .metadata.name + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 0 + create: true + - source: + kind: Service + version: v1 + name: apiserver-service + fieldPath: .metadata.namespace + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 1 + create: true diff --git a/config/apiserver/kind/kustomization.yaml b/config/apiserver/kind/kustomization.yaml new file mode 100644 index 00000000..f7246d53 --- /dev/null +++ b/config/apiserver/kind/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + +patchesStrategicMerge: + - patch-apiserver.yaml diff --git a/config/apiserver/kind/patch-apiserver.yaml b/config/apiserver/kind/patch-apiserver.yaml new file mode 100644 index 00000000..8678fff1 --- /dev/null +++ b/config/apiserver/kind/patch-apiserver.yaml @@ -0,0 +1,11 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: onmetal-api-net-system + name: onmetal-api-net-apiserver +spec: + template: + spec: + containers: + - name: apiserver + imagePullPolicy: Never diff --git a/config/apiserver/rbac/apiserver_role.yaml b/config/apiserver/rbac/apiserver_role.yaml new file mode 100644 index 00000000..c81e4e95 --- /dev/null +++ b/config/apiserver/rbac/apiserver_role.yaml @@ -0,0 +1,37 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: apiserver-role +rules: + - apiGroups: + - "" + resources: + - configmaps + - namespaces + verbs: + - get + - list + - watch + - apiGroups: + - compute.api.onmetal.de + resources: + - machinepools/proxy + verbs: + - '*' + - apiGroups: + - compute.api.onmetal.de + resources: + - machinepools + verbs: + - get + - list + - watch + - apiGroups: + - admissionregistration.k8s.io + resources: + - mutatingwebhookconfigurations + - validatingwebhookconfigurations + verbs: + - get + - list + - watch diff --git a/config/apiserver/rbac/apiserver_role_binding.yaml b/config/apiserver/rbac/apiserver_role_binding.yaml new file mode 100644 index 00000000..6468d9b7 --- /dev/null +++ b/config/apiserver/rbac/apiserver_role_binding.yaml @@ -0,0 +1,25 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: apiserver-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: apiserver-role +subjects: + - kind: ServiceAccount + name: apiserver + namespace: system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: apiserver-auth-delegator-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: + - kind: ServiceAccount + name: apiserver + namespace: system diff --git a/config/apiserver/rbac/apiserver_service_account.yaml b/config/apiserver/rbac/apiserver_service_account.yaml new file mode 100644 index 00000000..b5106797 --- /dev/null +++ b/config/apiserver/rbac/apiserver_service_account.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: apiserver + namespace: system diff --git a/config/apiserver/rbac/bucketpool_bootstrapper_role.yaml b/config/apiserver/rbac/bucketpool_bootstrapper_role.yaml new file mode 100644 index 00000000..3b3a8a93 --- /dev/null +++ b/config/apiserver/rbac/bucketpool_bootstrapper_role.yaml @@ -0,0 +1,20 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: storage.api.onmetal.de:system:bucketpools-bootstrapper +rules: + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/bucketpoolclient + verbs: + - create \ No newline at end of file diff --git a/config/apiserver/rbac/bucketpool_bootstrapper_rolebinding.yaml b/config/apiserver/rbac/bucketpool_bootstrapper_rolebinding.yaml new file mode 100644 index 00000000..04a68c72 --- /dev/null +++ b/config/apiserver/rbac/bucketpool_bootstrapper_rolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: storage.api.onmetal.de:system:bucketpools-bootstrapper +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: storage.api.onmetal.de:system:bucketpools-bootstrapper +subjects: + - kind: Group + # Group name has to match bootstrap group pattern \Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\ + # See https://github.com/kubernetes/kubernetes/blob/e8662a46dd27db774ec953dae15f93ae2d1a68c8/staging/src/k8s.io/cluster-bootstrap/token/api/types.go#L96 + name: system:bootstrappers:storage-api-onmetal-de:bucketpools + apiGroup: rbac.authorization.k8s.io diff --git a/config/onmetal-api-net/rbac/role.yaml b/config/apiserver/rbac/bucketpool_role.yaml similarity index 59% rename from config/onmetal-api-net/rbac/role.yaml rename to config/apiserver/rbac/bucketpool_role.yaml index 67b03fd2..a3c7713f 100644 --- a/config/onmetal-api-net/rbac/role.yaml +++ b/config/apiserver/rbac/bucketpool_role.yaml @@ -2,7 +2,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: manager-role + creationTimestamp: null + name: storage.api.onmetal.de:system:bucketpools rules: - apiGroups: - "" @@ -12,80 +13,79 @@ rules: - create - patch - apiGroups: - - apinet.api.onmetal.de + - "" resources: - - networks + - secrets verbs: + - create - get - list - patch - update - watch - apiGroups: - - apinet.api.onmetal.de + - certificates.k8s.io resources: - - networks/finalizers + - certificatesigningrequests verbs: - - update + - create + - get + - list + - watch - apiGroups: - - apinet.api.onmetal.de + - certificates.k8s.io resources: - - networks/status + - certificatesigningrequests/bucketpoolclient verbs: - - get - - patch - - update + - create - apiGroups: - - apinet.api.onmetal.de + - storage.api.onmetal.de resources: - - publicips + - bucketclasses verbs: - get - list - - patch - - update - watch - apiGroups: - - apinet.api.onmetal.de + - storage.api.onmetal.de resources: - - publicips/finalizers + - bucketpools verbs: + - create + - get + - list + - patch - update + - watch - apiGroups: - - apinet.api.onmetal.de + - storage.api.onmetal.de resources: - - publicips/status + - bucketpools/status verbs: - get - patch - update - apiGroups: - - authorization.k8s.io + - storage.api.onmetal.de resources: - - subjectaccessreviews - verbs: - - create -- apiGroups: - - certificates.k8s.io - resources: - - certificatesigningrequests + - buckets verbs: - get - list + - patch + - update - watch - apiGroups: - - certificates.k8s.io + - storage.api.onmetal.de resources: - - certificatesigningrequests/approval + - buckets/finalizers verbs: - - get - - patch - update - apiGroups: - - certificates.k8s.io - resourceNames: - - kubernetes.io/kube-apiserver-client + - storage.api.onmetal.de resources: - - signers + - buckets/status verbs: - - approve + - get + - patch + - update diff --git a/config/apiserver/rbac/bucketpool_rolebinding.yaml b/config/apiserver/rbac/bucketpool_rolebinding.yaml new file mode 100644 index 00000000..8a3b6923 --- /dev/null +++ b/config/apiserver/rbac/bucketpool_rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: storage.api.onmetal.de:system:bucketpools +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: storage.api.onmetal.de:system:bucketpools +subjects: + - kind: Group + name: storage.api.onmetal.de:system:bucketpools + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/kustomization.yaml b/config/apiserver/rbac/kustomization.yaml new file mode 100644 index 00000000..9abe84ca --- /dev/null +++ b/config/apiserver/rbac/kustomization.yaml @@ -0,0 +1,30 @@ +resources: + + # API Server roles + - apiserver_service_account.yaml + - apiserver_role.yaml + - apiserver_role_binding.yaml + + # MachinePool (bootstrapper) roles + - machinepool_role.yaml + - machinepool_rolebinding.yaml + - machinepool_bootstrapper_role.yaml + - machinepool_bootstrapper_rolebinding.yaml + + # VolumePool (bootstrapper) roles + - volumepool_role.yaml + - volumepool_rolebinding.yaml + - volumepool_bootstrapper_role.yaml + - volumepool_bootstrapper_rolebinding.yaml + + # BucketPool (bootstrapper) roles + - bucketpool_role.yaml + - bucketpool_rolebinding.yaml + - bucketpool_bootstrapper_role.yaml + - bucketpool_bootstrapper_rolebinding.yaml + + # Network Plugin (bootstrapper) roles + - networkplugin_role.yaml + - networkplugin_rolebinding.yaml + - networkplugin_bootstrapper_role.yaml + - networkplugin_bootstrapper_rolebinding.yaml diff --git a/config/apiserver/rbac/machinepool_bootstrapper_role.yaml b/config/apiserver/rbac/machinepool_bootstrapper_role.yaml new file mode 100644 index 00000000..65719baa --- /dev/null +++ b/config/apiserver/rbac/machinepool_bootstrapper_role.yaml @@ -0,0 +1,20 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: compute.api.onmetal.de:system:machinepools-bootstrapper +rules: + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/machinepoolclient + verbs: + - create \ No newline at end of file diff --git a/config/apiserver/rbac/machinepool_bootstrapper_rolebinding.yaml b/config/apiserver/rbac/machinepool_bootstrapper_rolebinding.yaml new file mode 100644 index 00000000..cb19a10d --- /dev/null +++ b/config/apiserver/rbac/machinepool_bootstrapper_rolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: compute.api.onmetal.de:system:machinepools-bootstrapper +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: compute.api.onmetal.de:system:machinepools-bootstrapper +subjects: + - kind: Group + # Group name has to match bootstrap group pattern \Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\ + # See https://github.com/kubernetes/kubernetes/blob/e8662a46dd27db774ec953dae15f93ae2d1a68c8/staging/src/k8s.io/cluster-bootstrap/token/api/types.go#L96 + name: system:bootstrappers:compute-api-onmetal-de:machinepools + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/machinepool_role.yaml b/config/apiserver/rbac/machinepool_role.yaml new file mode 100644 index 00000000..0a67b671 --- /dev/null +++ b/config/apiserver/rbac/machinepool_role.yaml @@ -0,0 +1,139 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: compute.api.onmetal.de:system:machinepools +rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/machinepoolclient + verbs: + - create +- apiGroups: + - compute.api.onmetal.de + resources: + - machineclasses + verbs: + - get + - list + - watch +- apiGroups: + - compute.api.onmetal.de + resources: + - machinepools + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - compute.api.onmetal.de + resources: + - machinepools/status + verbs: + - get + - patch + - update +- apiGroups: + - compute.api.onmetal.de + resources: + - machines + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - compute.api.onmetal.de + resources: + - machines/finalizers + verbs: + - update +- apiGroups: + - compute.api.onmetal.de + resources: + - machines/status + verbs: + - get + - patch + - update +- apiGroups: + - ipam.api.onmetal.de + resources: + - prefixes + verbs: + - get + - list + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - networks + verbs: + - get + - list + - watch +- apiGroups: + - storage.api.onmetal.de + resources: + - volumes + verbs: + - get + - list + - patch + - update + - watch diff --git a/config/apiserver/rbac/machinepool_rolebinding.yaml b/config/apiserver/rbac/machinepool_rolebinding.yaml new file mode 100644 index 00000000..a81f98cc --- /dev/null +++ b/config/apiserver/rbac/machinepool_rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: compute.api.onmetal.de:system:machinepools +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: compute.api.onmetal.de:system:machinepools +subjects: + - kind: Group + name: compute.api.onmetal.de:system:machinepools + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/networkplugin_bootstrapper_role.yaml b/config/apiserver/rbac/networkplugin_bootstrapper_role.yaml new file mode 100644 index 00000000..891b972c --- /dev/null +++ b/config/apiserver/rbac/networkplugin_bootstrapper_role.yaml @@ -0,0 +1,20 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: networking.api.onmetal.de:system:networkplugins-bootstrapper +rules: + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/networkpluginclient + verbs: + - create \ No newline at end of file diff --git a/config/apiserver/rbac/networkplugin_bootstrapper_rolebinding.yaml b/config/apiserver/rbac/networkplugin_bootstrapper_rolebinding.yaml new file mode 100644 index 00000000..c92695d6 --- /dev/null +++ b/config/apiserver/rbac/networkplugin_bootstrapper_rolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: networking.api.onmetal.de:system:networkplugins-bootstrapper +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: networking.api.onmetal.de:system:networkplugins-bootstrapper +subjects: + - kind: Group + # Group name has to match bootstrap group pattern \Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\ + # See https://github.com/kubernetes/kubernetes/blob/e8662a46dd27db774ec953dae15f93ae2d1a68c8/staging/src/k8s.io/cluster-bootstrap/token/api/types.go#L96 + name: system:bootstrappers:networking-api-onmetal-de:networkplugins + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/networkplugin_role.yaml b/config/apiserver/rbac/networkplugin_role.yaml new file mode 100644 index 00000000..640a0c6b --- /dev/null +++ b/config/apiserver/rbac/networkplugin_role.yaml @@ -0,0 +1,140 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: networking.api.onmetal.de:system:networkplugins +rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - networking.api.onmetal.de + resources: + - loadbalancers + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - loadbalancers/finalizers + verbs: + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - loadbalancers/status + verbs: + - get + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - natgateways + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - natgateways/finalizers + verbs: + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - natgateways/status + verbs: + - get + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - networks + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - networks/finalizers + verbs: + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - networks/status + verbs: + - get + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - virtualips + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.api.onmetal.de + resources: + - virtualips/finalizers + verbs: + - patch + - update +- apiGroups: + - networking.api.onmetal.de + resources: + - virtualips/status + verbs: + - get + - patch + - update +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/networkpluginclient + verbs: + - create +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - get + - list + - patch + - update + - watch diff --git a/config/apiserver/rbac/networkplugin_rolebinding.yaml b/config/apiserver/rbac/networkplugin_rolebinding.yaml new file mode 100644 index 00000000..a8c36251 --- /dev/null +++ b/config/apiserver/rbac/networkplugin_rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: networking.api.onmetal.de:system:networkplugins +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: networking.api.onmetal.de:system:networkplugins +subjects: + - kind: Group + name: networking.api.onmetal.de:system:networkplugins + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/volumepool_bootstrapper_role.yaml b/config/apiserver/rbac/volumepool_bootstrapper_role.yaml new file mode 100644 index 00000000..df0e3855 --- /dev/null +++ b/config/apiserver/rbac/volumepool_bootstrapper_role.yaml @@ -0,0 +1,20 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: storage.api.onmetal.de:system:volumepools-bootstrapper +rules: + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch + - apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/volumepoolclient + verbs: + - create \ No newline at end of file diff --git a/config/apiserver/rbac/volumepool_bootstrapper_rolebinding.yaml b/config/apiserver/rbac/volumepool_bootstrapper_rolebinding.yaml new file mode 100644 index 00000000..37f44a7a --- /dev/null +++ b/config/apiserver/rbac/volumepool_bootstrapper_rolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: storage.api.onmetal.de:system:volumepools-bootstrapper +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: storage.api.onmetal.de:system:volumepools-bootstrapper +subjects: + - kind: Group + # Group name has to match bootstrap group pattern \Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\ + # See https://github.com/kubernetes/kubernetes/blob/e8662a46dd27db774ec953dae15f93ae2d1a68c8/staging/src/k8s.io/cluster-bootstrap/token/api/types.go#L96 + name: system:bootstrappers:storage-api-onmetal-de:volumepools + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/rbac/volumepool_role.yaml b/config/apiserver/rbac/volumepool_role.yaml new file mode 100644 index 00000000..f6c2c104 --- /dev/null +++ b/config/apiserver/rbac/volumepool_role.yaml @@ -0,0 +1,91 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: storage.api.onmetal.de:system:volumepools +rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - create + - get + - list + - watch +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/volumepoolclient + verbs: + - create +- apiGroups: + - storage.api.onmetal.de + resources: + - volumeclasses + verbs: + - get + - list + - watch +- apiGroups: + - storage.api.onmetal.de + resources: + - volumepools + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - storage.api.onmetal.de + resources: + - volumepools/status + verbs: + - get + - patch + - update +- apiGroups: + - storage.api.onmetal.de + resources: + - volumes + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - storage.api.onmetal.de + resources: + - volumes/finalizers + verbs: + - update +- apiGroups: + - storage.api.onmetal.de + resources: + - volumes/status + verbs: + - get + - patch + - update diff --git a/config/apiserver/rbac/volumepool_rolebinding.yaml b/config/apiserver/rbac/volumepool_rolebinding.yaml new file mode 100644 index 00000000..b0d7c8ac --- /dev/null +++ b/config/apiserver/rbac/volumepool_rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: storage.api.onmetal.de:system:volumepools +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: storage.api.onmetal.de:system:volumepools +subjects: + - kind: Group + name: storage.api.onmetal.de:system:volumepools + apiGroup: rbac.authorization.k8s.io diff --git a/config/apiserver/server/kustomization.yaml b/config/apiserver/server/kustomization.yaml new file mode 100644 index 00000000..d47d8962 --- /dev/null +++ b/config/apiserver/server/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- server.yaml diff --git a/config/apiserver/server/server.yaml b/config/apiserver/server/server.yaml new file mode 100644 index 00000000..1736b105 --- /dev/null +++ b/config/apiserver/server/server.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: Namespace +metadata: + labels: + control-plane: apiserver + name: system +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: apiserver + namespace: system + labels: + control-plane: apiserver +spec: + selector: + matchLabels: + control-plane: apiserver + replicas: 1 + template: + metadata: + annotations: + kubectl.kubernetes.io/default-container: apiserver + labels: + control-plane: apiserver + spec: + securityContext: + runAsNonRoot: true + containers: + - command: + - /onmetal-apiserver + args: + - --etcd-servers=http://$(ONMETAL_API_APISERVER_ETCD_SERVICE_NAME):2379 + - --secure-port=8443 + - --audit-log-path=- + - --feature-gates=APIPriorityAndFairness=false + - --audit-log-maxage=0 + - --audit-log-maxbackup=0 + image: apiserver:latest + name: apiserver + securityContext: + allowPrivilegeEscalation: false + livenessProbe: + httpGet: + scheme: HTTPS + path: /healthz + port: 8443 + initialDelaySeconds: 20 + periodSeconds: 20 + readinessProbe: + httpGet: + scheme: HTTPS + path: /readyz + port: 8443 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 10m + memory: 64Mi + ports: + - containerPort: 8443 + name: apiserver + protocol: TCP + serviceAccountName: apiserver + terminationGracePeriodSeconds: 10 diff --git a/config/onmetal-api-net/default/kustomization.yaml b/config/controller/default/kustomization.yaml similarity index 99% rename from config/onmetal-api-net/default/kustomization.yaml rename to config/controller/default/kustomization.yaml index 50000a94..24e81a5b 100644 --- a/config/onmetal-api-net/default/kustomization.yaml +++ b/config/controller/default/kustomization.yaml @@ -13,7 +13,6 @@ namePrefix: onmetal-api-net- # someName: someValue resources: -- ../crd - ../rbac - ../manager # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in diff --git a/config/onmetal-api-net/default/manager_auth_proxy_patch.yaml b/config/controller/default/manager_auth_proxy_patch.yaml similarity index 100% rename from config/onmetal-api-net/default/manager_auth_proxy_patch.yaml rename to config/controller/default/manager_auth_proxy_patch.yaml diff --git a/config/onmetal-api-net/default/manager_config_patch.yaml b/config/controller/default/manager_config_patch.yaml similarity index 100% rename from config/onmetal-api-net/default/manager_config_patch.yaml rename to config/controller/default/manager_config_patch.yaml diff --git a/config/onmetal-api-net/kind/add-manager-args.yaml b/config/controller/kind/add-manager-args.yaml similarity index 100% rename from config/onmetal-api-net/kind/add-manager-args.yaml rename to config/controller/kind/add-manager-args.yaml diff --git a/config/onmetal-api-net/kind/kustomization.yaml b/config/controller/kind/kustomization.yaml similarity index 100% rename from config/onmetal-api-net/kind/kustomization.yaml rename to config/controller/kind/kustomization.yaml diff --git a/config/onmetal-api-net/kind/patch-controller.yaml b/config/controller/kind/patch-controller.yaml similarity index 100% rename from config/onmetal-api-net/kind/patch-controller.yaml rename to config/controller/kind/patch-controller.yaml diff --git a/config/onmetal-api-net/manager/controller_manager_config.yaml b/config/controller/manager/controller_manager_config.yaml similarity index 100% rename from config/onmetal-api-net/manager/controller_manager_config.yaml rename to config/controller/manager/controller_manager_config.yaml diff --git a/config/onmetal-api-net/manager/kustomization.yaml b/config/controller/manager/kustomization.yaml similarity index 100% rename from config/onmetal-api-net/manager/kustomization.yaml rename to config/controller/manager/kustomization.yaml diff --git a/config/onmetal-api-net/manager/manager.yaml b/config/controller/manager/manager.yaml similarity index 100% rename from config/onmetal-api-net/manager/manager.yaml rename to config/controller/manager/manager.yaml diff --git a/config/onmetal-api-net/prometheus/kustomization.yaml b/config/controller/prometheus/kustomization.yaml similarity index 100% rename from config/onmetal-api-net/prometheus/kustomization.yaml rename to config/controller/prometheus/kustomization.yaml diff --git a/config/onmetal-api-net/prometheus/monitor.yaml b/config/controller/prometheus/monitor.yaml similarity index 100% rename from config/onmetal-api-net/prometheus/monitor.yaml rename to config/controller/prometheus/monitor.yaml diff --git a/config/onmetal-api-net/rbac/apinetlet_bootstrapper_role.yaml b/config/controller/rbac/apinetlet_bootstrapper_role.yaml similarity index 100% rename from config/onmetal-api-net/rbac/apinetlet_bootstrapper_role.yaml rename to config/controller/rbac/apinetlet_bootstrapper_role.yaml diff --git a/config/onmetal-api-net/rbac/apinetlet_bootstrapper_rolebinding.yaml b/config/controller/rbac/apinetlet_bootstrapper_rolebinding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/apinetlet_bootstrapper_rolebinding.yaml rename to config/controller/rbac/apinetlet_bootstrapper_rolebinding.yaml diff --git a/config/controller/rbac/apinetlet_role.yaml b/config/controller/rbac/apinetlet_role.yaml new file mode 100644 index 00000000..c400100c --- /dev/null +++ b/config/controller/rbac/apinetlet_role.yaml @@ -0,0 +1,95 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: apinet.api.onmetal.de:system:apinetlets +rules: +- apiGroups: + - apinet.api.onmetal.de + resources: + - ips + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancerroutings + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancers + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgatewayautoscalers + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateways + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networks + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch diff --git a/config/onmetal-api-net/rbac/apinetlet_rolebinding.yaml b/config/controller/rbac/apinetlet_rolebinding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/apinetlet_rolebinding.yaml rename to config/controller/rbac/apinetlet_rolebinding.yaml diff --git a/config/onmetal-api-net/rbac/auth_proxy_client_clusterrole.yaml b/config/controller/rbac/auth_proxy_client_clusterrole.yaml similarity index 100% rename from config/onmetal-api-net/rbac/auth_proxy_client_clusterrole.yaml rename to config/controller/rbac/auth_proxy_client_clusterrole.yaml diff --git a/config/onmetal-api-net/rbac/auth_proxy_role.yaml b/config/controller/rbac/auth_proxy_role.yaml similarity index 100% rename from config/onmetal-api-net/rbac/auth_proxy_role.yaml rename to config/controller/rbac/auth_proxy_role.yaml diff --git a/config/onmetal-api-net/rbac/auth_proxy_role_binding.yaml b/config/controller/rbac/auth_proxy_role_binding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/auth_proxy_role_binding.yaml rename to config/controller/rbac/auth_proxy_role_binding.yaml diff --git a/config/onmetal-api-net/rbac/auth_proxy_service.yaml b/config/controller/rbac/auth_proxy_service.yaml similarity index 100% rename from config/onmetal-api-net/rbac/auth_proxy_service.yaml rename to config/controller/rbac/auth_proxy_service.yaml diff --git a/config/onmetal-api-net/rbac/kustomization.yaml b/config/controller/rbac/kustomization.yaml similarity index 100% rename from config/onmetal-api-net/rbac/kustomization.yaml rename to config/controller/rbac/kustomization.yaml diff --git a/config/onmetal-api-net/rbac/leader_election_role.yaml b/config/controller/rbac/leader_election_role.yaml similarity index 100% rename from config/onmetal-api-net/rbac/leader_election_role.yaml rename to config/controller/rbac/leader_election_role.yaml diff --git a/config/onmetal-api-net/rbac/leader_election_role_binding.yaml b/config/controller/rbac/leader_election_role_binding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/leader_election_role_binding.yaml rename to config/controller/rbac/leader_election_role_binding.yaml diff --git a/config/onmetal-api-net/rbac/metalnetlet_bootstrapper_role.yaml b/config/controller/rbac/metalnetlet_bootstrapper_role.yaml similarity index 100% rename from config/onmetal-api-net/rbac/metalnetlet_bootstrapper_role.yaml rename to config/controller/rbac/metalnetlet_bootstrapper_role.yaml diff --git a/config/onmetal-api-net/rbac/metalnetlet_bootstrapper_rolebinding.yaml b/config/controller/rbac/metalnetlet_bootstrapper_rolebinding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/metalnetlet_bootstrapper_rolebinding.yaml rename to config/controller/rbac/metalnetlet_bootstrapper_rolebinding.yaml diff --git a/config/controller/rbac/metalnetlet_role.yaml b/config/controller/rbac/metalnetlet_role.yaml new file mode 100644 index 00000000..e3c62fe9 --- /dev/null +++ b/config/controller/rbac/metalnetlet_role.yaml @@ -0,0 +1,54 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: apinet.api.onmetal.de:system:metalnetlet +rules: +- apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list + - watch +- apiGroups: + - networking.metalnet.onmetal.de + resources: + - loadbalancers + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.metalnet.onmetal.de + resources: + - networkinterfaces + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - networking.metalnet.onmetal.de + resources: + - networks + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch diff --git a/config/onmetal-api-net/rbac/metalnetlet_rolebinding.yaml b/config/controller/rbac/metalnetlet_rolebinding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/metalnetlet_rolebinding.yaml rename to config/controller/rbac/metalnetlet_rolebinding.yaml diff --git a/config/controller/rbac/role.yaml b/config/controller/rbac/role.yaml new file mode 100644 index 00000000..5acb86ce --- /dev/null +++ b/config/controller/rbac/role.yaml @@ -0,0 +1,190 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: manager-role +rules: +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - get + - list + - watch +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests/approval + verbs: + - get + - patch + - update +- apiGroups: + - certificates.k8s.io + resourceNames: + - kubernetes.io/kube-apiserver-client + resources: + - signers + verbs: + - approve +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - daemonsets + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - daemonsets/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - instances + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - ip + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - ipaddress + verbs: + - delete + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancers + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancers/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateway + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateway/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgatewayautoscalers + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgatewayautoscalers/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateways + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nattable + verbs: + - create + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkids + verbs: + - delete + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networks + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nodes + verbs: + - get + - list + - watch diff --git a/config/onmetal-api-net/rbac/role_binding.yaml b/config/controller/rbac/role_binding.yaml similarity index 100% rename from config/onmetal-api-net/rbac/role_binding.yaml rename to config/controller/rbac/role_binding.yaml diff --git a/config/onmetal-api-net/rbac/service_account.yaml b/config/controller/rbac/service_account.yaml similarity index 100% rename from config/onmetal-api-net/rbac/service_account.yaml rename to config/controller/rbac/service_account.yaml diff --git a/config/default/apiserver/kustomization.yaml b/config/default/apiserver/kustomization.yaml new file mode 100644 index 00000000..963d4dfa --- /dev/null +++ b/config/default/apiserver/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../apiserver/default + +patchesStrategicMerge: + - remove-namespace.yaml diff --git a/config/default/apiserver/remove-namespace.yaml b/config/default/apiserver/remove-namespace.yaml new file mode 100644 index 00000000..0c94e4c0 --- /dev/null +++ b/config/default/apiserver/remove-namespace.yaml @@ -0,0 +1,5 @@ +$patch: delete +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system diff --git a/config/default/controller/kustomization.yaml b/config/default/controller/kustomization.yaml new file mode 100644 index 00000000..18d6ac5e --- /dev/null +++ b/config/default/controller/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../controller/default + +patchesStrategicMerge: + - remove-namespace.yaml diff --git a/config/default/controller/remove-namespace.yaml b/config/default/controller/remove-namespace.yaml new file mode 100644 index 00000000..0c94e4c0 --- /dev/null +++ b/config/default/controller/remove-namespace.yaml @@ -0,0 +1,5 @@ +$patch: delete +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml new file mode 100644 index 00000000..51da5927 --- /dev/null +++ b/config/default/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - namespace.yaml + - apiserver + - controller diff --git a/config/default/namespace.yaml b/config/default/namespace.yaml new file mode 100644 index 00000000..1ab513cd --- /dev/null +++ b/config/default/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system + labels: + control-plane: apiserver-controller diff --git a/config/etcdless/apiserver/kustomization.yaml b/config/etcdless/apiserver/kustomization.yaml new file mode 100644 index 00000000..cbbc70dc --- /dev/null +++ b/config/etcdless/apiserver/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../apiserver/etcdless + +patchesStrategicMerge: + - remove-namespace.yaml diff --git a/config/etcdless/apiserver/remove-namespace.yaml b/config/etcdless/apiserver/remove-namespace.yaml new file mode 100644 index 00000000..0c94e4c0 --- /dev/null +++ b/config/etcdless/apiserver/remove-namespace.yaml @@ -0,0 +1,5 @@ +$patch: delete +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system diff --git a/config/etcdless/controller/kustomization.yaml b/config/etcdless/controller/kustomization.yaml new file mode 100644 index 00000000..18d6ac5e --- /dev/null +++ b/config/etcdless/controller/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../controller/default + +patchesStrategicMerge: + - remove-namespace.yaml diff --git a/config/etcdless/controller/remove-namespace.yaml b/config/etcdless/controller/remove-namespace.yaml new file mode 100644 index 00000000..0c94e4c0 --- /dev/null +++ b/config/etcdless/controller/remove-namespace.yaml @@ -0,0 +1,5 @@ +$patch: delete +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system diff --git a/config/etcdless/kustomization.yaml b/config/etcdless/kustomization.yaml new file mode 100644 index 00000000..51da5927 --- /dev/null +++ b/config/etcdless/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - namespace.yaml + - apiserver + - controller diff --git a/config/etcdless/namespace.yaml b/config/etcdless/namespace.yaml new file mode 100644 index 00000000..1ab513cd --- /dev/null +++ b/config/etcdless/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: onmetal-api-net-system + labels: + control-plane: apiserver-controller diff --git a/config/metalnetlet/metalnet-rbac/role.yaml b/config/metalnetlet/metalnet-rbac/role.yaml index a5ba2513..f855fac3 100644 --- a/config/metalnetlet/metalnet-rbac/role.yaml +++ b/config/metalnetlet/metalnet-rbac/role.yaml @@ -1,26 +1,55 @@ +--- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: + creationTimestamp: null namespace: system name: metalnet-role rules: +- apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list + - watch - apiGroups: - networking.metalnet.onmetal.de resources: - - networks + - loadbalancers verbs: + - create + - delete + - deletecollection - get - list - patch - update - watch +- apiGroups: + - networking.metalnet.onmetal.de + resources: + - networkinterfaces + verbs: - create - delete - deletecollection + - get + - list + - patch + - update + - watch - apiGroups: - networking.metalnet.onmetal.de resources: - - networks/finalizers + - networks verbs: + - create + - delete + - deletecollection + - get + - list - patch - update + - watch diff --git a/config/metalnetlet/rbac/role.yaml b/config/metalnetlet/rbac/role.yaml index 9980617e..a29bf503 100644 --- a/config/metalnetlet/rbac/role.yaml +++ b/config/metalnetlet/rbac/role.yaml @@ -2,26 +2,26 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: + creationTimestamp: null name: manager-role rules: - apiGroups: - "" resources: - - secrets + - events verbs: - create - - get - - list - patch - - update - - watch - apiGroups: - - apinet.api.onmetal.de + - "" resources: - - networks + - secrets verbs: + - create - get - list + - patch + - update - watch - apiGroups: - authentication.k8s.io @@ -50,3 +50,121 @@ rules: - certificatesigningrequests/metalnetletclient verbs: - create +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - instances + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - instances/finalizers + verbs: + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - instances/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - loadbalancerroutings + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - natgateways + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nattables + verbs: + - get + - list + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces/finalizers + verbs: + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networkinterfaces/status + verbs: + - get + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networks + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - networks/finalizers + verbs: + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nodes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nodes/finalizers + verbs: + - patch + - update +- apiGroups: + - core.apinet.api.onmetal.de + resources: + - nodes/status + verbs: + - get + - patch + - update diff --git a/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_networks.yaml b/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_networks.yaml deleted file mode 100644 index 059576ee..00000000 --- a/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_networks.yaml +++ /dev/null @@ -1,78 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: networks.apinet.api.onmetal.de -spec: - group: apinet.api.onmetal.de - names: - kind: Network - listKind: NetworkList - plural: networks - singular: network - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.vni - name: VNI - type: string - - jsonPath: .status.conditions[?(@.type == "Allocated")].reason - name: State - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: Network is the schema for the publicips API. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - properties: - vni: - description: VNI is the requested network vni. Pointer to distinguish - between explicitly set and unset. - format: int32 - maximum: 16777215 - minimum: 0 - type: integer - type: object - status: - properties: - conditions: - description: Conditions are the conditions of a network. - items: - properties: - message: - type: string - reason: - type: string - status: - type: string - type: - type: string - required: - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_publicips.yaml b/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_publicips.yaml deleted file mode 100644 index 736f4298..00000000 --- a/config/onmetal-api-net/crd/bases/apinet.api.onmetal.de_publicips.yaml +++ /dev/null @@ -1,83 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: publicips.apinet.api.onmetal.de -spec: - group: apinet.api.onmetal.de - names: - kind: PublicIP - listKind: PublicIPList - plural: publicips - singular: publicip - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.ipFamily - name: IPFamily - type: string - - jsonPath: .spec.ip - name: IP - type: string - - jsonPath: .status.conditions[?(@.type == "Allocated")].reason - name: State - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: PublicIP is the schema for the publicips API. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - properties: - ip: - description: IP is the ip of the public IP. Pointer to distinguish - between unset and explicit zero. - type: string - ipFamily: - description: IPFamily is the ip family of the public ip. - type: string - required: - - ipFamily - type: object - status: - properties: - conditions: - description: Conditions are the conditions of a PublicIP. - items: - properties: - message: - type: string - reason: - type: string - status: - type: string - type: - type: string - required: - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/onmetal-api-net/crd/kustomization.yaml b/config/onmetal-api-net/crd/kustomization.yaml deleted file mode 100644 index 52248c3a..00000000 --- a/config/onmetal-api-net/crd/kustomization.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# This kustomization.yaml is not intended to be run by itself, -# since it depends on service name and namespace that are out of this kustomize package. -# It should be run by config/default -resources: -- bases/apinet.api.onmetal.de_networks.yaml -- bases/apinet.api.onmetal.de_publicips.yaml -#+kubebuilder:scaffold:crdkustomizeresource - -patchesStrategicMerge: -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. -# patches here are for enabling the conversion webhook for each CRD -#- patches/webhook_in_kubeconfigs.yaml -#- patches/webhook_in_kubeapiservers.yaml -#- patches/webhook_in_kubecontrollermanagers.yaml -#+kubebuilder:scaffold:crdkustomizewebhookpatch - -# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. -# patches here are for enabling the CA injection for each CRD -#- patches/cainjection_in_kubeconfigs.yaml -#- patches/cainjection_in_kubeapiservers.yaml -#- patches/cainjection_in_kubecontrollermanagers.yaml -#+kubebuilder:scaffold:crdkustomizecainjectionpatch - -# the following config is for teaching kustomize how to do kustomization for CRDs. -configurations: -- kustomizeconfig.yaml diff --git a/config/onmetal-api-net/crd/kustomizeconfig.yaml b/config/onmetal-api-net/crd/kustomizeconfig.yaml deleted file mode 100644 index ec5c150a..00000000 --- a/config/onmetal-api-net/crd/kustomizeconfig.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is for teaching kustomize how to substitute name and namespace reference in CRD -nameReference: -- kind: Service - version: v1 - fieldSpecs: - - kind: CustomResourceDefinition - version: v1 - group: apiextensions.k8s.io - path: spec/conversion/webhook/clientConfig/service/name - -namespace: -- kind: CustomResourceDefinition - version: v1 - group: apiextensions.k8s.io - path: spec/conversion/webhook/clientConfig/service/namespace - create: false - -varReference: -- path: metadata/annotations diff --git a/config/onmetal-api-net/rbac/apinetlet_role.yaml b/config/onmetal-api-net/rbac/apinetlet_role.yaml deleted file mode 100644 index 79810e18..00000000 --- a/config/onmetal-api-net/rbac/apinetlet_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: apinet.api.onmetal.de:system:apinetlets -rules: -- apiGroups: - - apinet.api.onmetal.de - resources: - - networks - verbs: - - get - - list - - patch - - update - - watch - - create - - delete - - deletecollection -- apiGroups: - - apinet.api.onmetal.de - resources: - - publicips - verbs: - - get - - list - - patch - - update - - watch - - create - - delete - - deletecollection diff --git a/config/onmetal-api-net/rbac/metalnetlet_role.yaml b/config/onmetal-api-net/rbac/metalnetlet_role.yaml deleted file mode 100644 index 8eb2bd74..00000000 --- a/config/onmetal-api-net/rbac/metalnetlet_role.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - creationTimestamp: null - name: apinet.api.onmetal.de:system:metalnetlets -rules: -- apiGroups: - - apinet.api.onmetal.de - resources: - - networks - verbs: - - get - - list - - patch - - update - - watch - - create - - delete diff --git a/config/onmetal-api-net/samples/apinet_v1alpha1_network.yaml b/config/onmetal-api-net/samples/apinet_v1alpha1_network.yaml deleted file mode 100644 index a157d399..00000000 --- a/config/onmetal-api-net/samples/apinet_v1alpha1_network.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: apinet.api.onmetal.de/v1alpha1 -kind: Network -metadata: - name: my-network diff --git a/config/onmetal-api-net/samples/apinet_v1alpha1_publicip.yaml b/config/onmetal-api-net/samples/apinet_v1alpha1_publicip.yaml deleted file mode 100644 index bc786e98..00000000 --- a/config/onmetal-api-net/samples/apinet_v1alpha1_publicip.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: apinet.api.onmetal.de/v1alpha1 -kind: PublicIP -metadata: - name: my-publicip -spec: - ipFamily: IPv4 diff --git a/flag/flag.go b/flag/flag.go index 60acca53..b83e1c6f 100644 --- a/flag/flag.go +++ b/flag/flag.go @@ -17,11 +17,11 @@ package flag import ( "bytes" "encoding/csv" - "flag" "io" "net/netip" "strings" + "github.com/spf13/pflag" "go4.org/netipx" ) @@ -97,8 +97,8 @@ func (v *ipPrefixesVar) String() string { return "[" + out + "]" } -func IPPrefixesVar(p *[]netip.Prefix, name string, value []netip.Prefix, usage string) { - flag.Var(newIPPrefixesVar(value, p), name, usage) +func IPPrefixesVar(fs *pflag.FlagSet, p *[]netip.Prefix, name string, value []netip.Prefix, usage string) { + fs.Var(newIPPrefixesVar(value, p), name, usage) } func IPSetFromPrefixes(prefixes []netip.Prefix) (*netipx.IPSet, error) { diff --git a/go.mod b/go.mod index f9e4546d..6b1c3cbe 100644 --- a/go.mod +++ b/go.mod @@ -1,55 +1,71 @@ module github.com/onmetal/onmetal-api-net -go 1.20 +go 1.21 require ( + github.com/bits-and-blooms/bitset v1.8.0 github.com/go-logr/logr v1.2.4 - github.com/onmetal/controller-utils v0.8.0 + github.com/google/uuid v1.3.0 + github.com/onmetal/controller-utils v0.8.1 github.com/onmetal/metalnet v0.1.0 - github.com/onmetal/onmetal-api v0.1.2-0.20230530094909-67f87469764c - github.com/onsi/ginkgo/v2 v2.9.5 - github.com/onsi/gomega v1.27.7 + github.com/onmetal/onmetal-api v0.1.2-0.20230908130149-c56ec12cc66c + github.com/onsi/ginkgo/v2 v2.12.0 + github.com/onsi/gomega v1.27.10 + github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 go4.org/netipx v0.0.0-20220812043211-3cc044ffd68d golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 - k8s.io/api v0.27.2 - k8s.io/apimachinery v0.27.2 - k8s.io/apiserver v0.27.2 - k8s.io/client-go v0.27.2 + k8s.io/api v0.27.4 + k8s.io/apimachinery v0.27.4 + k8s.io/apiserver v0.27.4 + k8s.io/client-go v0.27.4 + k8s.io/component-base v0.27.4 + k8s.io/klog/v2 v2.100.1 + k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f k8s.io/utils v0.0.0-20230209194617-a36077c30491 - sigs.k8s.io/controller-runtime v0.15.0 + sigs.k8s.io/controller-runtime v0.15.1 + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 ) require ( + github.com/NYTimes/gziphandler v1.1.1 // indirect + github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect + github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.4.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.2.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.1 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/cel-go v0.12.6 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/gofuzz v1.1.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -58,6 +74,11 @@ require ( github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect + github.com/stoewer/go-strcase v1.2.0 // indirect + go.etcd.io/etcd/api/v3 v3.5.7 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect + go.etcd.io/etcd/client/v3 v3.5.7 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.1 // indirect go.opentelemetry.io/otel v1.10.0 // indirect go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect @@ -70,28 +91,30 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/crypto v0.12.0 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.9.1 // indirect + golang.org/x/tools v0.12.0 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect - google.golang.org/grpc v1.55.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/grpc v1.58.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.27.2 // indirect - k8s.io/component-base v0.27.2 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-aggregator v0.27.2 // indirect - k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect + k8s.io/apiextensions-apiserver v0.27.4 // indirect + k8s.io/kms v0.27.4 // indirect + k8s.io/kube-aggregator v0.27.4 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index ab17c631..a8fee68f 100644 --- a/go.sum +++ b/go.sum @@ -13,12 +13,17 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= +cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= @@ -32,17 +37,23 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= +github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= +github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= +github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= @@ -63,13 +74,20 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.4.0 h1:y9YHcjnjynCd/DVbg5j9L/33jQM3MxJlbj/zWskzfGU= +github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -79,7 +97,10 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= @@ -100,17 +121,21 @@ github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8= -github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -123,7 +148,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -144,7 +168,10 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= +github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -159,8 +186,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -178,7 +205,13 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QGdLI4y34qQGjGWO0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= @@ -188,7 +221,11 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -201,6 +238,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -210,6 +248,7 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -217,17 +256,16 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= -github.com/onmetal/controller-utils v0.8.0 h1:8rMDhtsoFGq1x26sha8W+Y7mGK5E4ALpudfoIL/w6hI= -github.com/onmetal/controller-utils v0.8.0/go.mod h1:w57S36LruaLsRZ7DXC9E7TCa+H2iiXZW3JhvT8Hdilc= +github.com/onmetal/controller-utils v0.8.1 h1:2B7s/2SBfEtrp0u+1VDyxmecYTBmOIX9u+ZmQhEZqIo= +github.com/onmetal/controller-utils v0.8.1/go.mod h1:qbStb7obY06G70iOg7wuKYRH+MiJ6emZvzuUEAj5VUQ= github.com/onmetal/metalnet v0.1.0 h1:KnwFz7/3IA/WzPDZOcpVPzV1Y09y1LZWxsz8tWeAfbc= github.com/onmetal/metalnet v0.1.0/go.mod h1:Vgl0Ux3wN6gpcA5D+I3uqiX+ApmV4eGEa1AgiyZ1SSw= -github.com/onmetal/onmetal-api v0.1.2-0.20230530094909-67f87469764c h1:ZeoSKIyws7OUW55D9eIMkpgL6Ivog64i/8bmoPKrd7Y= -github.com/onmetal/onmetal-api v0.1.2-0.20230530094909-67f87469764c/go.mod h1:MP0kSC4pqC9PwaRCWhscgvpKf5ta5piElxExup9CYW4= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= -github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= +github.com/onmetal/onmetal-api v0.1.2-0.20230908130149-c56ec12cc66c h1:p8MU9AWHed6MxLrR5BkfBEeoyi49jeiWi4nJY9c5VOc= +github.com/onmetal/onmetal-api v0.1.2-0.20230908130149-c56ec12cc66c/go.mod h1:b1+WDg4M5jaA++635nqOu0b7nzyWeCgILrN2zo53o08= +github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= +github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -244,9 +282,16 @@ github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJf github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= @@ -263,21 +308,40 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd/api/v3 v3.5.7 h1:sbcmosSVesNrWOJ58ZQFitHMdncusIifYcrBfwrlJSY= +go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= go.etcd.io/etcd/client/pkg/v3 v3.5.7 h1:y3kf5Gbp4e4q7egZdn5T7W9TSHUvkClN6u+Rq9mEOmg= +go.etcd.io/etcd/client/pkg/v3 v3.5.7/go.mod h1:o0Abi1MK86iad3YrWhgUsbGx1pmTS+hrORWc2CamuhY= +go.etcd.io/etcd/client/v2 v2.305.7 h1:AELPkjNR3/igjbO7CjyF1fPuVPjrblliiKj+Y6xSGOU= +go.etcd.io/etcd/client/v2 v2.305.7/go.mod h1:GQGT5Z3TBuAQGvgPfhR7VPySu/SudxmEkRq9BgzFU6s= go.etcd.io/etcd/client/v3 v3.5.7 h1:u/OhpiuCgYY8awOHlhIhmGIGpxfBU/GZBUP3m/3/Iz4= +go.etcd.io/etcd/client/v3 v3.5.7/go.mod h1:sOWmj9DZUMyAngS7QQwCyAXXAL6WhgTOPLNS/NabQgw= +go.etcd.io/etcd/pkg/v3 v3.5.7 h1:obOzeVwerFwZ9trMWapU/VjDcYUJb5OfgC1zqEGWO/0= +go.etcd.io/etcd/pkg/v3 v3.5.7/go.mod h1:kcOfWt3Ov9zgYdOiJ/o1Y9zFfLhQjylTgL4Lru8opRo= +go.etcd.io/etcd/raft/v3 v3.5.7 h1:aN79qxLmV3SvIq84aNTliYGmjwsW6NqJSnqmI1HLJKc= +go.etcd.io/etcd/raft/v3 v3.5.7/go.mod h1:TflkAb/8Uy6JFBxcRaH2Fr6Slm9mCPVdI2efzxY96yU= +go.etcd.io/etcd/server/v3 v3.5.7 h1:BTBD8IJUV7YFgsczZMHhMTS67XuA4KpRquL0MFOJGRk= +go.etcd.io/etcd/server/v3 v3.5.7/go.mod h1:gxBgT84issUVBRpZ3XkW1T55NjOb4vZZRI4wVvNhf4A= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 h1:xFSRQBbXF6VvYRf2lqMJXxoB72XI1K/azav8TekHHSw= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0/go.mod h1:h8TWwRAhQpOd0aM5nYsRD8+flnkj+526GEIVlarH7eY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.1 h1:sxoY9kG1s1WpSYNyzm24rlwH4lnRYFXUVVBmKMBfRgw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.1/go.mod h1:9NiG9I2aHTKkcxqCILhjtyNA1QEiCjdBACv4IvrFQ+c= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= @@ -302,6 +366,9 @@ go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= @@ -313,7 +380,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -347,7 +415,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -376,16 +445,16 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -396,7 +465,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -427,19 +497,19 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -488,8 +558,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -552,8 +622,12 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -570,8 +644,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o= +google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -585,8 +659,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -596,6 +670,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -613,23 +688,24 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo= -k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4= -k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laClBV6Bo= -k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= -k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= -k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= -k8s.io/apiserver v0.27.2 h1:p+tjwrcQEZDrEorCZV2/qE8osGTINPuS5ZNqWAvKm5E= -k8s.io/apiserver v0.27.2/go.mod h1:EsOf39d75rMivgvvwjJ3OW/u9n1/BmUMK5otEOJrb1Y= -k8s.io/client-go v0.27.2 h1:vDLSeuYvCHKeoQRhCXjxXO45nHVv2Ip4Fe0MfioMrhE= -k8s.io/client-go v0.27.2/go.mod h1:tY0gVmUsHrAmjzHX9zs7eCjxcBsf8IiNe7KQ52biTcQ= -k8s.io/component-base v0.27.2 h1:neju+7s/r5O4x4/txeUONNTS9r1HsPbyoPBAtHsDCpo= -k8s.io/component-base v0.27.2/go.mod h1:5UPk7EjfgrfgRIuDBFtsEFAe4DAvP3U+M8RTzoSJkpo= +k8s.io/api v0.27.4 h1:0pCo/AN9hONazBKlNUdhQymmnfLRbSZjd5H5H3f0bSs= +k8s.io/api v0.27.4/go.mod h1:O3smaaX15NfxjzILfiln1D8Z3+gEYpjEpiNA/1EVK1Y= +k8s.io/apiextensions-apiserver v0.27.4 h1:ie1yZG4nY/wvFMIR2hXBeSVq+HfNzib60FjnBYtPGSs= +k8s.io/apiextensions-apiserver v0.27.4/go.mod h1:KHZaDr5H9IbGEnSskEUp/DsdXe1hMQ7uzpQcYUFt2bM= +k8s.io/apimachinery v0.27.4 h1:CdxflD4AF61yewuid0fLl6bM4a3q04jWel0IlP+aYjs= +k8s.io/apimachinery v0.27.4/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= +k8s.io/apiserver v0.27.4 h1:ncZ0MBR9yQ/Gf34rtu1EK+HqT8In1YpfAUINu/Akvho= +k8s.io/apiserver v0.27.4/go.mod h1:GDEFRfFZ4/l+pAvwYRnoSfz0K4j3TWiN4WsG2KnRteE= +k8s.io/client-go v0.27.4 h1:vj2YTtSJ6J4KxaC88P4pMPEQECWMY8gqPqsTgUKzvjk= +k8s.io/client-go v0.27.4/go.mod h1:ragcly7lUlN0SRPk5/ZkGnDjPknzb37TICq07WhI6Xc= +k8s.io/component-base v0.27.4 h1:Wqc0jMKEDGjKXdae8hBXeskRP//vu1m6ypC+gwErj4c= +k8s.io/component-base v0.27.4/go.mod h1:hoiEETnLc0ioLv6WPeDt8vD34DDeB35MfQnxCARq3kY= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kms v0.27.2 h1:wCdmPCa3kubcVd3AssOeaVjLQSu45k5g/vruJ3iqwDU= -k8s.io/kube-aggregator v0.27.2 h1:jfHoPip+qN/fn3OcrYs8/xMuVYvkJHKo0H0DYciqdns= -k8s.io/kube-aggregator v0.27.2/go.mod h1:mwrTt4ESjQ7A6847biwohgZWn8P/KzSFHegEScbSGY4= +k8s.io/kms v0.27.4 h1:FeT17HfqxZMP7dTq3Gpa9dG05iP3J3wgGtqGh1SUoN0= +k8s.io/kms v0.27.4/go.mod h1:0BY6tkfa+zOP85u8yE7iNNf1Yx7rEZnRQSWLEbsSk+w= +k8s.io/kube-aggregator v0.27.4 h1:WdK9iiBr32G8bWfpUEFVQl70RZO2dU19ZAktUXL5JFc= +k8s.io/kube-aggregator v0.27.4/go.mod h1:+eG83gkAyh0uilQEAOgheeQW4hr+PkyV+5O1nLGsjlM= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= @@ -639,11 +715,11 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 h1:trsWhjU5jZrx6UvFu4WzQDrN7Pga4a7Qg+zcfcj64PA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2/go.mod h1:+qG7ISXqCDVVcyO8hLn12AKVYYUjM7ftlqsqmrhMZE0= -sigs.k8s.io/controller-runtime v0.15.0 h1:ML+5Adt3qZnMSYxZ7gAverBLNPSMQEibtzAgp0UPojU= -sigs.k8s.io/controller-runtime v0.15.0/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= +sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= +sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/hack/cluster-controller-gen.sh b/hack/cluster-controller-gen.sh new file mode 100755 index 00000000..1a284a86 --- /dev/null +++ b/hack/cluster-controller-gen.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CONTROLLER_GEN=${CONTROLLER_GEN:-"controller-gen"} + +declare cluster rbac paths output + +while [[ $# -gt 0 ]]; do + case $1 in + cluster*) + cluster="$1" + cluster="${cluster#cluster=}" + shift + ;; + rbac*) + rbac="$1" + shift + ;; + paths*) + paths="$1" + # Remove 'paths=' prefix and '/...' suffix. + paths="${paths#paths=}" + paths="${paths%/...}" + shift + ;; + output:rbac:artifacts:config*) + output="$1" + output="${output#output:rbac:artifacts:config=}" + shift + ;; + *) + echo "Unknown option/arg $1" + exit 1 + ;; + esac +done + +tmp_dir="$(mktemp -d)" +trap 'rm -rf $tmp_dir' EXIT + +combined="$tmp_dir/combined.go" + +echo "package extracted" > "$combined" +echo "module extracted" > "$tmp_dir/go.mod" + +grep -rh "//+cluster=$cluster" "$paths" | sed -e "s/cluster=$cluster://" >> "$combined" + +"$CONTROLLER_GEN" "$rbac" "paths=$tmp_dir" "output:rbac:artifacts:config=$output" +sed -i 's/ClusterRole/Role/g' "$output/role.yaml" +sed -i '/creationTimestamp: null/a\ namespace: system' "$output/role.yaml" diff --git a/hack/promote-let-role.sh b/hack/promote-let-role.sh new file mode 100755 index 00000000..75aa5e7d --- /dev/null +++ b/hack/promote-let-role.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -euo pipefail + +INPUT_ROLE="$1" +OUTPUT_CLUSTER_ROLE="$2" +NAME="$3" + +cp "$INPUT_ROLE" "$OUTPUT_CLUSTER_ROLE" +sed -i "s/name: .*/name: $NAME/g" "$OUTPUT_CLUSTER_ROLE" +sed -i 's/Role/ClusterRole/g' "$OUTPUT_CLUSTER_ROLE" +sed -i '/namespace: system/d' "$OUTPUT_CLUSTER_ROLE" diff --git a/hack/types-to-internal-types.sh b/hack/types-to-internal-types.sh new file mode 100755 index 00000000..c697b1ef --- /dev/null +++ b/hack/types-to-internal-types.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +EXTERNAL_API_DIR="$SCRIPT_DIR"/../api/core/v1alpha1 +INTERNAL_API_DIR="$SCRIPT_DIR"/../internal/apis/core + +rsync -a --exclude="{doc.go zz_generated.deepcopy.go}" "$EXTERNAL_API_DIR"/ "$INTERNAL_API_DIR" + +function sed-all() { + exp="$1" + find "$INTERNAL_API_DIR" -maxdepth 1 -name "*.go" -exec sed -i -E "$exp" {} + +} + +function sed-single() { + f="$1" + exp="$2" + sed -i -E "$exp" "$INTERNAL_API_DIR/$f" +} + +sed-all 's/[[:space:]]+`json:[^$]*//g' +sed-all 's/package v1alpha1/package core/g' +sed-all 's/Version: "v1alpha1"/Version: runtime.APIVersionInternal/g' +sed-all 's/Package v1alpha1/Package core/g' +sed-all 's/github.com\/onmetal\/onmetal-api-net\/api\/v1alpha1/github.com\/onmetal\/onmetal-api-net\/internal\/apis\/core/g' +sed-all 's/v1alpha1/core/g' +sed-all '/metav1\.AddToGroupVersion\(scheme, SchemeGroupVersion\)/d' + +sed-single "register.go" '/metav1 "k8s.io\/apimachinery\/pkg\/apis\/meta\/v1"/d' diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh new file mode 100755 index 00000000..edc24ce3 --- /dev/null +++ b/hack/update-codegen.sh @@ -0,0 +1,154 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +export TERM="xterm-256color" + +bold="$(tput bold)" +blue="$(tput setaf 4)" +normal="$(tput sgr0)" + +function qualify-gvs() { + APIS_PKG="$1" + GROUPS_WITH_VERSIONS="$2" + join_char="" + res="" + + for GVs in ${GROUPS_WITH_VERSIONS}; do + IFS=: read -r G Vs <<<"${GVs}" + + for V in ${Vs//,/ }; do + res="$res$join_char$APIS_PKG/$G/$V" + join_char="," + done + done + + echo "$res" +} + +function qualify-gs() { + APIS_PKG="$1" + unset GROUPS + IFS=' ' read -ra GROUPS <<< "$2" + join_char="" + res="" + + for G in "${GROUPS[@]}"; do + res="$res$join_char$APIS_PKG/$G" + join_char="," + done + + echo "$res" +} + +VGOPATH="$VGOPATH" +MODELS_SCHEMA="$MODELS_SCHEMA" +CLIENT_GEN="$CLIENT_GEN" +DEEPCOPY_GEN="$DEEPCOPY_GEN" +LISTER_GEN="$LISTER_GEN" +INFORMER_GEN="$INFORMER_GEN" +DEFAULTER_GEN="$DEFAULTER_GEN" +CONVERSION_GEN="$CONVERSION_GEN" +OPENAPI_GEN="$OPENAPI_GEN" +APPLYCONFIGURATION_GEN="$APPLYCONFIGURATION_GEN" + +VIRTUAL_GOPATH="$(mktemp -d)" +trap 'rm -rf "$GOPATH"' EXIT + +# Setup virtual GOPATH so the codegen tools work as expected. +(cd "$SCRIPT_DIR/.."; go mod download && "$VGOPATH" -o "$VIRTUAL_GOPATH") + +export GOROOT="${GOROOT:-"$(go env GOROOT)"}" +export GOPATH="$VIRTUAL_GOPATH" +export GO111MODULE=off + +ONMETAL_API_NET_ROOT="github.com/onmetal/onmetal-api-net" +ALL_GROUPS="core" +ALL_VERSION_GROUPS="core:v1alpha1" + +echo "${bold}Public types${normal}" + +echo "Generating ${blue}deepcopy${normal}" +"$DEEPCOPY_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")" \ + -O zz_generated.deepcopy + +echo "Generating ${blue}openapi${normal}" +"$OPENAPI_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")" \ + --input-dirs "$ONMETAL_API_NET_ROOT/apimachinery/api/net" \ + --input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/version" \ + --input-dirs "k8s.io/api/core/v1" \ + --input-dirs "k8s.io/apimachinery/pkg/api/resource" \ + --output-package "$ONMETAL_API_NET_ROOT/client-go/openapi" \ + -O zz_generated.openapi \ + --report-filename "$SCRIPT_DIR/../client-go/openapi/api_violations.report" + +echo "Generating ${blue}applyconfiguration${normal}" +applyconfigurationgen_external_apis+=("k8s.io/apimachinery/pkg/apis/meta/v1") +applyconfigurationgen_external_apis+=("$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")") +applyconfigurationgen_external_apis_csv=$(IFS=,; echo "${applyconfigurationgen_external_apis[*]}") +"$APPLYCONFIGURATION_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "${applyconfigurationgen_external_apis_csv}" \ + --openapi-schema <("$MODELS_SCHEMA" --openapi-package "$ONMETAL_API_NET_ROOT/client-go/openapi" --openapi-title "onmetal-api-net") \ + --output-package "$ONMETAL_API_NET_ROOT/client-go/applyconfigurations" + +echo "Generating ${blue}client${normal}" +"$CLIENT_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input "$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")" \ + --output-package "$ONMETAL_API_NET_ROOT/client-go" \ + --apply-configuration-package "$ONMETAL_API_NET_ROOT/client-go/applyconfigurations" \ + --clientset-name "onmetalapinet" \ + --input-base "" + +echo "Generating ${blue}lister${normal}" +"$LISTER_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")" \ + --output-package "$ONMETAL_API_NET_ROOT/client-go/listers" + +echo "Generating ${blue}informer${normal}" +"$INFORMER_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/api" "$ALL_VERSION_GROUPS")" \ + --versioned-clientset-package "$ONMETAL_API_NET_ROOT/client-go/onmetalapinet" \ + --listers-package "$ONMETAL_API_NET_ROOT/client-go/listers" \ + --output-package "$ONMETAL_API_NET_ROOT/client-go/informers" \ + --single-directory + +echo "${bold}Internal types${normal}" + +echo "Generating ${blue}deepcopy${normal}" +"$DEEPCOPY_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gs "$ONMETAL_API_NET_ROOT/internal/apis" "$ALL_GROUPS")" \ + -O zz_generated.deepcopy + +echo "Generating ${blue}defaulter${normal}" +"$DEFAULTER_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/internal/apis" "$ALL_VERSION_GROUPS")" \ + -O zz_generated.defaults + +echo "Generating ${blue}conversion${normal}" +"$CONVERSION_GEN" \ + --output-base "$GOPATH/src" \ + --go-header-file "$SCRIPT_DIR/boilerplate.go.txt" \ + --input-dirs "$(qualify-gs "$ONMETAL_API_NET_ROOT/internal/apis" "$ALL_GROUPS")" \ + --input-dirs "$(qualify-gvs "$ONMETAL_API_NET_ROOT/internal/apis" "$ALL_VERSION_GROUPS")" \ + -O zz_generated.conversion diff --git a/internal/apis/core/common_types.go b/internal/apis/core/common_types.go new file mode 100644 index 00000000..b2799cea --- /dev/null +++ b/internal/apis/core/common_types.go @@ -0,0 +1,41 @@ +// Copyright 2022 OnMetal 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 core + +const ( + ReconcileRequestAnnotation = "reconcile.apinet.api.onmetal.de/requestedAt" + + // APINetletsGroup is the system rbac group all apinetlets are in. + APINetletsGroup = "apinet.api.onmetal.de:system:apinetlets" + + // APINetletUserNamePrefix is the prefix all apinetlet users should have. + APINetletUserNamePrefix = "apinet.api.onmetal.de:system:apinetlet:" + + // MetalnetletsGroup is the system rbac group all metalnetlets are in. + MetalnetletsGroup = "apinet.api.onmetal.de:system:metalnetlets" + + // MetalnetletUserNamePrefix is the prefix all metalnetlet users should have. + MetalnetletUserNamePrefix = "apinet.api.onmetal.de:system:metalnetlet:" +) + +// APINetletCommonName constructs the common name for a certificate of an apinetlet user. +func APINetletCommonName(name string) string { + return APINetletUserNamePrefix + name +} + +// MetalnetletCommonName constructs the common name for a certificate of a metalnetlet user. +func MetalnetletCommonName(name string) string { + return MetalnetletUserNamePrefix + name +} diff --git a/internal/apis/core/daemonset_types.go b/internal/apis/core/daemonset_types.go new file mode 100644 index 00000000..4aebea3c --- /dev/null +++ b/internal/apis/core/daemonset_types.go @@ -0,0 +1,52 @@ +// Copyright 2023 OnMetal 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 core + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type DaemonSetSpec struct { + // Selector selects all Instance that are managed by this daemon set. + Selector *metav1.LabelSelector + + // Template is the instance template. + Template InstanceTemplate +} + +type DaemonSetStatus struct { + CollisionCount *int32 +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// DaemonSet is the schema for the daemonsets API. +type DaemonSet struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec DaemonSetSpec + Status DaemonSetStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DaemonSetList contains a list of DaemonSet. +type DaemonSetList struct { + metav1.TypeMeta + metav1.ListMeta + Items []DaemonSet +} diff --git a/internal/apis/core/doc.go b/internal/apis/core/doc.go new file mode 100644 index 00000000..7b61aa1c --- /dev/null +++ b/internal/apis/core/doc.go @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 by the OnMetal 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. + */ + +// +k8s:deepcopy-gen=package +// +k8s:openapi-gen=true +// +k8s:defaulter-gen=TypeMeta +// +k8s:protobuf-gen=package +// +groupName=core.apinet.api.onmetal.de + +// Package core is the core version of the API. +package core // import "github.com/onmetal/onmetal-api-net/api/core/core" diff --git a/internal/apis/core/install/install.go b/internal/apis/core/install/install.go new file mode 100644 index 00000000..714d3217 --- /dev/null +++ b/internal/apis/core/install/install.go @@ -0,0 +1,28 @@ +// Copyright 2023 OnMetal 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 install + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/v1alpha1" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +func Install(scheme *runtime.Scheme) { + utilruntime.Must(core.AddToScheme(scheme)) + utilruntime.Must(v1alpha1.AddToScheme(scheme)) + utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)) +} diff --git a/internal/apis/core/instance_types.go b/internal/apis/core/instance_types.go new file mode 100644 index 00000000..7600eafc --- /dev/null +++ b/internal/apis/core/instance_types.go @@ -0,0 +1,196 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type InstanceType string + +const ( + InstanceTypeLoadBalancer InstanceType = "LoadBalancer" +) + +type InstanceSpec struct { + // Type specifies the InstanceType to deploy. + Type InstanceType + + // LoadBalancerType is the load balancer type this instance is for. + LoadBalancerType LoadBalancerType + + // NetworkRef references the network the instance is on. + NetworkRef corev1.LocalObjectReference + + // IPs are the IPs of the instance. + IPs []net.IP + + // LoadBalancerPorts are the load balancer ports of this instance. + LoadBalancerPorts []LoadBalancerPort + + // Affinity are affinity constraints. + Affinity *Affinity + + // TopologySpreadConstraints describes how a group of instances ought to spread across topology + // domains. Scheduler will schedule instances in a way which abides by the constraints. + // All topologySpreadConstraints are ANDed. + TopologySpreadConstraints []TopologySpreadConstraint + + // NodeRef references the node hosting the load balancer instance. + // Will be set by the scheduler if empty. + NodeRef *corev1.LocalObjectReference +} + +type Affinity struct { + NodeAffinity *NodeAffinity + InstanceAntiAffinity *InstanceAntiAffinity +} + +type InstanceAntiAffinity struct { + // RequiredDuringSchedulingIgnoredDuringExecution specifies anti-affinity requirements at + // scheduling time, that, if not met, will cause the instance not be scheduled onto the node. + // When there are multiple elements, the lists of nodes corresponding to each + // instanceAffinityTerm are intersected, i.e. all terms must be satisfied. + RequiredDuringSchedulingIgnoredDuringExecution []InstanceAffinityTerm +} + +// InstanceAffinityTerm defines a set of instances (namely those matching the labelSelector that this instance should be +// co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose +// value of the label with key matches that of any node on which a instance of the set of instances is running. +type InstanceAffinityTerm struct { + // LabelSelector over a set of resources, in this case instances. + LabelSelector *metav1.LabelSelector + // TopologyKey indicates that this instance should be co-located (affinity) or not co-located (anti-affinity) + // with the instances matching the labelSelector, where co-located is defined as running on a + // node whose value of the label with key topologyKey matches that of any node on which any of the + // selected instances is running. + // Empty topologyKey is not allowed. + TopologyKey string +} + +type NodeAffinity struct { + RequiredDuringSchedulingIgnoredDuringExecution *NodeSelector +} + +// NodeSelector represents the union of the results of one or more queries +// over a set of nodes; that is, it represents the OR of the selectors represented +// by the node selector terms. +type NodeSelector struct { + // Required. A list of node selector terms. The terms are ORed. + NodeSelectorTerms []NodeSelectorTerm +} + +// NodeSelectorTerm matches no objects if it's empty. The requirements of the selector are ANDed. +type NodeSelectorTerm struct { + // MatchExpressions matches nodes by the label selector requirements. + MatchExpressions []NodeSelectorRequirement + // MatchFields matches the nodes by their fields. + MatchFields []NodeSelectorRequirement +} + +// NodeSelectorRequirement is a requirement for a selector. It's a combination of the key to match, the operator +// to match with, and zero to n values, depending on the operator. +type NodeSelectorRequirement struct { + // Key is the key the selector applies to. + Key string + // Operator represents the key's relationship to the values. + // Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + Operator NodeSelectorOperator + // Values are the values to relate the key to via the operator. + Values []string +} + +// NodeSelectorOperator is the set of operators that can be used in +// a node selector requirement. +type NodeSelectorOperator string + +const ( + NodeSelectorOpIn NodeSelectorOperator = "In" + NodeSelectorOpNotIn NodeSelectorOperator = "NotIn" + NodeSelectorOpExists NodeSelectorOperator = "Exists" + NodeSelectorOpDoesNotExist NodeSelectorOperator = "DoesNotExist" + NodeSelectorOpGt NodeSelectorOperator = "Gt" + NodeSelectorOpLt NodeSelectorOperator = "Lt" +) + +type UnsatisfiableConstraintAction string + +const ( + // DoNotSchedule instructs the scheduler not to schedule the instance + // when constraints are not satisfied. + DoNotSchedule UnsatisfiableConstraintAction = "DoNotSchedule" +) + +// TopologySpreadConstraint specifies how to spread matching instances among the given topology. +type TopologySpreadConstraint struct { + // MaxSkew describes the degree to which instances may be unevenly distributed. + // When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference + // between the number of matching instances in the target topology and the global minimum. + // The global minimum is the minimum number of matching instances in an eligible domain + // or zero if the number of eligible domains is less than MinDomains. + MaxSkew int32 + // TopologyKey is the key of node labels. Nodes that have a label with this key + // and identical values are considered to be in the same topology. + // We consider each as a "bucket", and try to put balanced number + // of instances into each bucket. + // We define a domain as a particular instance of a topology. + // Also, we define an eligible domain as a domain whose nodes meet the requirements of + // nodeAffinityPolicy and nodeTaintsPolicy. + TopologyKey string + // WhenUnsatisfiable indicates how to deal with a instance if it doesn't satisfy + // the spread constraint. + // - DoNotSchedule (default) tells the scheduler not to schedule it. + // - ScheduleAnyway tells the scheduler to schedule the instance in any location, + // but giving higher precedence to topologies that would help reduce the + // skew. + WhenUnsatisfiable UnsatisfiableConstraintAction + // LabelSelector is used to find matching instances. + // Instances that match this label selector are counted to determine the number of instances + // in their corresponding topology domain. + LabelSelector *metav1.LabelSelector +} + +type InstanceStatus struct { + IPs []net.IP + CollisionCount *int32 +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Instance is the schema for the instances API. +type Instance struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec InstanceSpec + Status InstanceStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InstanceList contains a list of Instance. +type InstanceList struct { + metav1.TypeMeta + metav1.ListMeta + Items []Instance +} + +type InstanceTemplate struct { + metav1.ObjectMeta + Spec InstanceSpec +} diff --git a/internal/apis/core/ip_types.go b/internal/apis/core/ip_types.go new file mode 100644 index 00000000..183d78e9 --- /dev/null +++ b/internal/apis/core/ip_types.go @@ -0,0 +1,75 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type IPType string + +const ( + IPTypePublic IPType = "Public" +) + +type IPSpec struct { + Type IPType + IPFamily corev1.IPFamily + IP net.IP + ClaimRef *IPClaimRef +} + +type IPClaimRef struct { + Group string + Resource string + Name string + UID types.UID +} + +type IPStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// IP is the schema for the ips API. +type IP struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec IPSpec + Status IPStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IPList contains a list of IP. +type IPList struct { + metav1.TypeMeta + metav1.ListMeta + Items []IP +} + +func IsIPClaimedBy(ip *IP, claimer metav1.Object) bool { + claimRef := ip.Spec.ClaimRef + if claimRef == nil { + return false + } + + return claimRef.UID == claimer.GetUID() +} diff --git a/internal/apis/core/ipaddress_types.go b/internal/apis/core/ipaddress_types.go new file mode 100644 index 00000000..1f9a6728 --- /dev/null +++ b/internal/apis/core/ipaddress_types.go @@ -0,0 +1,59 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type IPAddressSpec struct { + IP net.IP + ClaimRef IPAddressClaimRef +} + +type IPAddressClaimRef struct { + Group string + Resource string + Namespace string + Name string + UID types.UID +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// IPAddress is the schema for the ipaddresses API. +type IPAddress struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec IPAddressSpec +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IPAddressList contains a list of IPAddress. +type IPAddressList struct { + metav1.TypeMeta + metav1.ListMeta + Items []IPAddress +} + +func IsIPAddressClaimedBy(addr *IPAddress, claimer metav1.Object) bool { + return addr.Spec.ClaimRef.UID == claimer.GetUID() +} diff --git a/internal/apis/core/loadbalancer_types.go b/internal/apis/core/loadbalancer_types.go new file mode 100644 index 00000000..60d2175a --- /dev/null +++ b/internal/apis/core/loadbalancer_types.go @@ -0,0 +1,114 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type LoadBalancerType string + +const ( + LoadBalancerTypePublic LoadBalancerType = "Public" + LoadBalancerTypeInternal LoadBalancerType = "Internal" +) + +type LoadBalancerSpec struct { + // Type specifies the type of load balancer. + Type LoadBalancerType + + // NetworkRef references the network the load balancer is part of. + NetworkRef corev1.LocalObjectReference + + // IPs specifies the IPs of the load balancer. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + IPs []LoadBalancerIP + + // Ports are the ports the load balancer should allow. + // If empty, the load balancer allows all ports. + Ports []LoadBalancerPort + + // Selector selects all Instance that are managed by this daemon set. + Selector *metav1.LabelSelector + + // Template is the instance template. + Template InstanceTemplate +} + +type LoadBalancerIP struct { + // Name is the name of the load balancer IP. + Name string + // IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, + // will be defaulted by using the IP family of IP. + // If only IPFamily is specified, a random IP of that family will be allocated if possible. + IPFamily corev1.IPFamily + // IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible. + IP net.IP +} + +type LoadBalancerPort struct { + // Protocol is the protocol the load balancer should allow. + // If not specified, defaults to TCP. + Protocol *corev1.Protocol + // Port is the port to allow. + Port int32 + // EndPort marks the end of the port range to allow. + // If unspecified, only a single port, Port, will be allowed. + EndPort *int32 +} + +type LoadBalancerStatus struct { + // CollisionCount is used to construct names for IP addresses for the load balancer. + CollisionCount *int32 + // IPs are the IPs used currently by the load balancer. + IPs []net.IP +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// LoadBalancer is the schema for the loadbalancers API. +type LoadBalancer struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec LoadBalancerSpec + Status LoadBalancerStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// LoadBalancerList contains a list of LoadBalancer. +type LoadBalancerList struct { + metav1.TypeMeta + metav1.ListMeta + Items []LoadBalancer +} + +func LoadBalancerDaemonSetName(lbName string) string { + return "lb-" + lbName +} + +func GetLoadBalancerIPs(loadBalancer *LoadBalancer) []net.IP { + res := make([]net.IP, len(loadBalancer.Spec.IPs)) + for i, ip := range loadBalancer.Spec.IPs { + res[i] = ip.IP + } + return res +} diff --git a/internal/apis/core/loadbalancerrouting_types.go b/internal/apis/core/loadbalancerrouting_types.go new file mode 100644 index 00000000..49944f65 --- /dev/null +++ b/internal/apis/core/loadbalancerrouting_types.go @@ -0,0 +1,63 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// LoadBalancerRouting is the schema for the loadbalancerroutings API. +type LoadBalancerRouting struct { + metav1.TypeMeta + metav1.ObjectMeta + + // IPs are the IPs the routing is for. + IPs []net.IP + + Destinations []LoadBalancerDestination +} + +// LoadBalancerDestination is the destination of the load balancer. +type LoadBalancerDestination struct { + // IP is the target IP. + IP net.IP + // TargetRef is the target providing the destination. + TargetRef *LoadBalancerTargetRef +} + +// LoadBalancerTargetRef is a load balancer target. +type LoadBalancerTargetRef struct { + // UID is the UID of the target. + UID types.UID + // Name is the name of the target. + Name string + // NodeRef references the node the destination network interface is on. + NodeRef corev1.LocalObjectReference +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// LoadBalancerRoutingList contains a list of LoadBalancerRouting. +type LoadBalancerRoutingList struct { + metav1.TypeMeta + metav1.ListMeta + Items []LoadBalancerRouting +} diff --git a/internal/apis/core/natgateway_types.go b/internal/apis/core/natgateway_types.go new file mode 100644 index 00000000..2608d01e --- /dev/null +++ b/internal/apis/core/natgateway_types.go @@ -0,0 +1,81 @@ +// Copyright 2022 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type NATGatewaySpec struct { + // IPFamily is the IP family of the NAT gateway. + IPFamily corev1.IPFamily + + // NetworkRef references the network the NAT gateway is part of. + NetworkRef corev1.LocalObjectReference + + // IPs specifies the IPs of the NAT gateway. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + IPs []NATGatewayIP + + // PortsPerNetworkInterface specifies how many ports to allocate per network interface. + PortsPerNetworkInterface int32 +} + +type NATGatewayIP struct { + // Name is the semantic name of the NAT gateway IP. + Name string + // IP specifies a specific IP to allocate. If empty, a random IP will be allocated if possible. + IP net.IP +} + +type NATGatewayStatus struct { + // UsedNATIPs is the number of NAT IPs in-use. + UsedNATIPs int64 + // RequestedNATIPs is the number of requested NAT IPs. + RequestedNATIPs int64 +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATGateway is the schema for the natgateways API. +type NATGateway struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NATGatewaySpec + Status NATGatewayStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATGatewayList contains a list of NATGateway. +type NATGatewayList struct { + metav1.TypeMeta + metav1.ListMeta + Items []NATGateway +} + +func GetNATGatewayIPs(natGateway *NATGateway) []net.IP { + res := make([]net.IP, len(natGateway.Spec.IPs)) + for i, ip := range natGateway.Spec.IPs { + res[i] = ip.IP + } + return res +} diff --git a/internal/apis/core/natgatewayautoscaler_types.go b/internal/apis/core/natgatewayautoscaler_types.go new file mode 100644 index 00000000..58a48949 --- /dev/null +++ b/internal/apis/core/natgatewayautoscaler_types.go @@ -0,0 +1,54 @@ +// Copyright 2022 OnMetal 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 core + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type NATGatewayAutoscalerSpec struct { + // NATGatewayRef points to the target NATGateway to scale. + NATGatewayRef corev1.LocalObjectReference + + // MinPublicIPs is the minimum number of public IPs to allocate for a NAT Gateway. + MinPublicIPs *int32 + // MaxPublicIPs is the maximum number of public IPs to allocate for a NAT Gateway. + MaxPublicIPs *int32 +} + +type NATGatewayAutoscalerStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATGatewayAutoscaler is the schema for the natgatewayautoscalers API. +type NATGatewayAutoscaler struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NATGatewayAutoscalerSpec + Status NATGatewayAutoscalerStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATGatewayAutoscalerList contains a list of NATGatewayAutoscaler. +type NATGatewayAutoscalerList struct { + metav1.TypeMeta + metav1.ListMeta + Items []NATGatewayAutoscaler +} diff --git a/internal/apis/core/nattable_types.go b/internal/apis/core/nattable_types.go new file mode 100644 index 00000000..608f7642 --- /dev/null +++ b/internal/apis/core/nattable_types.go @@ -0,0 +1,70 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NATTable is the schema for the nattables API. +type NATTable struct { + metav1.TypeMeta + metav1.ObjectMeta + + // IPs specifies how to NAT the IPs for the NAT gateway. + IPs []NATIP +} + +type NATIP struct { + // IP is the IP to NAT. + IP net.IP + // Sections are the sections of the NATIP. + Sections []NATIPSection +} + +type NATTableIPTargetRef struct { + // UID is the UID of the target. + UID types.UID + // Name is the name of the target. + Name string + // NodeRef references the node the destination network interface is on. + NodeRef corev1.LocalObjectReference +} + +type NATIPSection struct { + // IP is the source IP. + IP net.IP + // Port is the start port of the section. + Port int32 + // EndPort is the end port of the section + EndPort int32 + // TargetRef references the entity having the IP. + TargetRef *NATTableIPTargetRef +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NATTableList contains a list of NATTable. +type NATTableList struct { + metav1.TypeMeta + metav1.ListMeta + Items []NATTable +} diff --git a/internal/apis/core/network_types.go b/internal/apis/core/network_types.go new file mode 100644 index 00000000..b5c24f77 --- /dev/null +++ b/internal/apis/core/network_types.go @@ -0,0 +1,48 @@ +// Copyright 2022 OnMetal 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 core + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type NetworkSpec struct { + // ID is the ID of the network. + ID string +} + +type NetworkStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// Network is the schema for the networks API. +type Network struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NetworkSpec + Status NetworkStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkList contains a list of Network. +type NetworkList struct { + metav1.TypeMeta + metav1.ListMeta + Items []Network +} diff --git a/internal/apis/core/networkid_types.go b/internal/apis/core/networkid_types.go new file mode 100644 index 00000000..56ef14b3 --- /dev/null +++ b/internal/apis/core/networkid_types.go @@ -0,0 +1,57 @@ +// Copyright 2023 OnMetal 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 core + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type NetworkIDSpec struct { + ClaimRef NetworkIDClaimRef +} + +type NetworkIDClaimRef struct { + Group string + Resource string + Namespace string + Name string + UID types.UID +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// NetworkID is the schema for the networkids API. +type NetworkID struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NetworkIDSpec +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkIDList contains a list of NetworkID. +type NetworkIDList struct { + metav1.TypeMeta + metav1.ListMeta + Items []NetworkID +} + +func IsNetworkIDClaimedBy(networkID *NetworkID, claimer metav1.Object) bool { + return networkID.Spec.ClaimRef.UID == claimer.GetUID() +} diff --git a/internal/apis/core/networkinterface_types.go b/internal/apis/core/networkinterface_types.go new file mode 100644 index 00000000..32173510 --- /dev/null +++ b/internal/apis/core/networkinterface_types.go @@ -0,0 +1,137 @@ +// Copyright 2023 OnMetal 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 core + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +type NetworkInterfaceSpec struct { + // NodeRef is the node the network interface is hosted on. + NodeRef corev1.LocalObjectReference + + // NetworkRef references the network that the network interface is in. + NetworkRef corev1.LocalObjectReference + + // IPs are the internal IPs of the network interface. + IPs []net.IP + + // Prefixes are additional prefixes to route to the network interface. + Prefixes []net.IPPrefix + + // NATs specify the NAT of the network interface IP family. + // Can only be set if there is no matching IP family in PublicIPs. + NATs []NetworkInterfaceNAT + + // PublicIPs are the public IPs the network interface should have. + // +optional + // +patchMergeKey=name + // +patchStrategy=merge,retainKeys + PublicIPs []NetworkInterfacePublicIP +} + +type NetworkInterfaceNAT struct { + // IPFamily is the IP family of the handling NAT gateway. + IPFamily corev1.IPFamily + // ClaimRef references the NAT claim handling the network interface's NAT. + ClaimRef NetworkInterfaceNATClaimRef +} + +type NetworkInterfaceNATClaimRef struct { + // Name is the name of the claiming NAT gateway. + Name string + // UID is the uid of the claiming NAT gateway. + UID types.UID +} + +type NetworkInterfacePublicIP struct { + // Name is the semantic name of the network interface public IP. + Name string + // IPFamily is the IP family of the IP. Has to match IP if specified. If unspecified and IP is specified, + // will be defaulted by using the IP family of IP. + // If only IPFamily is specified, a random IP of that family will be allocated if possible. + IPFamily corev1.IPFamily + // IP specifies a specific IP to allocate. If empty, a random ephemeral IP will be allocated. + IP net.IP +} + +type NetworkInterfaceState string + +const ( + // NetworkInterfaceStateReady is used for any NetworkInterface that is ready. + NetworkInterfaceStateReady NetworkInterfaceState = "Ready" + // NetworkInterfaceStatePending is used for any NetworkInterface that is in an intermediate state. + NetworkInterfaceStatePending NetworkInterfaceState = "Pending" + // NetworkInterfaceStateError is used for any NetworkInterface that is some error occurred. + NetworkInterfaceStateError NetworkInterfaceState = "Error" +) + +// PCIAddress is a PCI address. +type PCIAddress struct { + Domain string + Bus string + Slot string + Function string +} + +type NetworkInterfaceStatus struct { + State NetworkInterfaceState + PCIAddress *PCIAddress + Prefixes []net.IPPrefix + PublicIPs []net.IP + NATIPs []net.IP +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient + +// NetworkInterface is the schema for the networkinterfaces API. +type NetworkInterface struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NetworkInterfaceSpec + Status NetworkInterfaceStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NetworkInterfaceList contains a list of NetworkInterface. +type NetworkInterfaceList struct { + metav1.TypeMeta + metav1.ListMeta + Items []NetworkInterface +} + +func GetNetworkInterfaceNATClaimer(nic *NetworkInterface, ipFamily corev1.IPFamily) *NetworkInterfaceNATClaimRef { + for _, nicNAT := range nic.Spec.NATs { + if nicNAT.IPFamily == ipFamily { + claimRef := nicNAT.ClaimRef + return &claimRef + } + } + return nil +} + +func GetNetworkInterfacePublicIPs(nic *NetworkInterface) []net.IP { + res := make([]net.IP, len(nic.Spec.PublicIPs)) + for i, publicIP := range nic.Spec.PublicIPs { + res[i] = publicIP.IP + } + return res +} diff --git a/internal/apis/core/node_types.go b/internal/apis/core/node_types.go new file mode 100644 index 00000000..f060a88b --- /dev/null +++ b/internal/apis/core/node_types.go @@ -0,0 +1,47 @@ +// Copyright 2023 OnMetal 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 core + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type NodeSpec struct { +} + +type NodeStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced + +// Node is the schema for the nodes API. +type Node struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec NodeSpec + Status NodeStatus +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// NodeList contains a list of Node. +type NodeList struct { + metav1.TypeMeta + metav1.ListMeta + Items []Node +} diff --git a/internal/apis/core/register.go b/internal/apis/core/register.go new file mode 100644 index 00000000..4e36e160 --- /dev/null +++ b/internal/apis/core/register.go @@ -0,0 +1,72 @@ +// Copyright 2022 OnMetal 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 core contains API Schema definitions for the apinet core API group +// +groupName=core.apinet.api.onmetal.de +package core + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the name of the apinet group. +const GroupName = "core.apinet.api.onmetal.de" + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} + + // 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 +) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &DaemonSet{}, + &DaemonSetList{}, + &Instance{}, + &InstanceList{}, + &IP{}, + &IPList{}, + &IPAddress{}, + &IPAddressList{}, + &LoadBalancer{}, + &LoadBalancerList{}, + &LoadBalancerRouting{}, + &LoadBalancerRoutingList{}, + &NATGateway{}, + &NATGatewayList{}, + &NATGatewayAutoscaler{}, + &NATGatewayAutoscalerList{}, + &NATTable{}, + &NATTableList{}, + &Network{}, + &NetworkList{}, + &NetworkID{}, + &NetworkIDList{}, + &NetworkInterface{}, + &NetworkInterfaceList{}, + &Node{}, + &NodeList{}, + ) + return nil +} diff --git a/internal/apis/core/v1alpha1/conversions.go b/internal/apis/core/v1alpha1/conversions.go new file mode 100644 index 00000000..f877c5bb --- /dev/null +++ b/internal/apis/core/v1alpha1/conversions.go @@ -0,0 +1,39 @@ +// Copyright 2023 OnMetal 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" + + "k8s.io/apimachinery/pkg/runtime" +) + +func addConversionFuncs(scheme *runtime.Scheme) error { + if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("IP"), + func(label, value string) (string, string, error) { + switch label { + case "metadata.name", + "metadata.namespace", + "spec.ip": + return label, value, nil + default: + return "", "", fmt.Errorf("field label not supported: %s", label) + } + }, + ); err != nil { + return err + } + return nil +} diff --git a/internal/apis/core/v1alpha1/defaults.go b/internal/apis/core/v1alpha1/defaults.go new file mode 100644 index 00000000..6dd30893 --- /dev/null +++ b/internal/apis/core/v1alpha1/defaults.go @@ -0,0 +1,30 @@ +// Copyright 2023 OnMetal 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/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/runtime" +) + +func addDefaultingFuncs(scheme *runtime.Scheme) error { + return RegisterDefaults(scheme) +} + +func SetDefaults_IPSpec(spec *v1alpha1.IPSpec) { + if spec.IPFamily == "" && spec.IP.IsValid() { + spec.IPFamily = spec.IP.Family() + } +} diff --git a/internal/apis/core/v1alpha1/doc.go b/internal/apis/core/v1alpha1/doc.go new file mode 100644 index 00000000..afd614d3 --- /dev/null +++ b/internal/apis/core/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 by the OnMetal 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. + */ + +// +k8s:conversion-gen=github.com/onmetal/onmetal-api-net/internal/apis/core +// +k8s:conversion-gen-external-types=github.com/onmetal/onmetal-api-net/api/core/v1alpha1 +// +k8s:defaulter-gen=TypeMeta +// +k8s:defaulter-gen-input=github.com/onmetal/onmetal-api-net/api/core/v1alpha1 + +// Package v1alpha1 is the v1alpha1 version of the API. +package v1alpha1 // import "github.com/onmetal/onmetal-api-net/internal/apis/core/v1alpha1" diff --git a/api/v1alpha1/groupversion_info.go b/internal/apis/core/v1alpha1/register.go similarity index 58% rename from api/v1alpha1/groupversion_info.go rename to internal/apis/core/v1alpha1/register.go index 3fe274a0..1384d1d6 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/internal/apis/core/v1alpha1/register.go @@ -13,22 +13,32 @@ // limitations under the License. // Package v1alpha1 contains API Schema definitions for the apinet v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=apinet.api.onmetal.de +// +groupName=core.apinet.api.onmetal.de package v1alpha1 import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +const ( + GroupName = "core.apinet.api.onmetal.de" ) var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "apinet.api.onmetal.de", Version: "v1alpha1"} + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + localSchemeBuilder = &v1alpha1.SchemeBuilder // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme + AddToScheme = localSchemeBuilder.AddToScheme ) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func init() { + localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs) +} diff --git a/internal/apis/core/v1alpha1/zz_generated.conversion.go b/internal/apis/core/v1alpha1/zz_generated.conversion.go new file mode 100644 index 00000000..d43ee6e0 --- /dev/null +++ b/internal/apis/core/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,2460 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * Copyright (c) 2022 by the OnMetal 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 conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + unsafe "unsafe" + + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + core "github.com/onmetal/onmetal-api-net/internal/apis/core" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + types "k8s.io/apimachinery/pkg/types" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*v1alpha1.Affinity)(nil), (*core.Affinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Affinity_To_core_Affinity(a.(*v1alpha1.Affinity), b.(*core.Affinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.Affinity)(nil), (*v1alpha1.Affinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_Affinity_To_v1alpha1_Affinity(a.(*core.Affinity), b.(*v1alpha1.Affinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.DaemonSet)(nil), (*core.DaemonSet)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_DaemonSet_To_core_DaemonSet(a.(*v1alpha1.DaemonSet), b.(*core.DaemonSet), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.DaemonSet)(nil), (*v1alpha1.DaemonSet)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_DaemonSet_To_v1alpha1_DaemonSet(a.(*core.DaemonSet), b.(*v1alpha1.DaemonSet), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.DaemonSetList)(nil), (*core.DaemonSetList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_DaemonSetList_To_core_DaemonSetList(a.(*v1alpha1.DaemonSetList), b.(*core.DaemonSetList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.DaemonSetList)(nil), (*v1alpha1.DaemonSetList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_DaemonSetList_To_v1alpha1_DaemonSetList(a.(*core.DaemonSetList), b.(*v1alpha1.DaemonSetList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.DaemonSetSpec)(nil), (*core.DaemonSetSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec(a.(*v1alpha1.DaemonSetSpec), b.(*core.DaemonSetSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.DaemonSetSpec)(nil), (*v1alpha1.DaemonSetSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec(a.(*core.DaemonSetSpec), b.(*v1alpha1.DaemonSetSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.DaemonSetStatus)(nil), (*core.DaemonSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus(a.(*v1alpha1.DaemonSetStatus), b.(*core.DaemonSetStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.DaemonSetStatus)(nil), (*v1alpha1.DaemonSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus(a.(*core.DaemonSetStatus), b.(*v1alpha1.DaemonSetStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IP)(nil), (*core.IP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IP_To_core_IP(a.(*v1alpha1.IP), b.(*core.IP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IP)(nil), (*v1alpha1.IP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IP_To_v1alpha1_IP(a.(*core.IP), b.(*v1alpha1.IP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPAddress)(nil), (*core.IPAddress)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPAddress_To_core_IPAddress(a.(*v1alpha1.IPAddress), b.(*core.IPAddress), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPAddress)(nil), (*v1alpha1.IPAddress)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPAddress_To_v1alpha1_IPAddress(a.(*core.IPAddress), b.(*v1alpha1.IPAddress), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPAddressClaimRef)(nil), (*core.IPAddressClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef(a.(*v1alpha1.IPAddressClaimRef), b.(*core.IPAddressClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPAddressClaimRef)(nil), (*v1alpha1.IPAddressClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef(a.(*core.IPAddressClaimRef), b.(*v1alpha1.IPAddressClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPAddressList)(nil), (*core.IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPAddressList_To_core_IPAddressList(a.(*v1alpha1.IPAddressList), b.(*core.IPAddressList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPAddressList)(nil), (*v1alpha1.IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPAddressList_To_v1alpha1_IPAddressList(a.(*core.IPAddressList), b.(*v1alpha1.IPAddressList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPAddressSpec)(nil), (*core.IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec(a.(*v1alpha1.IPAddressSpec), b.(*core.IPAddressSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPAddressSpec)(nil), (*v1alpha1.IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec(a.(*core.IPAddressSpec), b.(*v1alpha1.IPAddressSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPClaimRef)(nil), (*core.IPClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPClaimRef_To_core_IPClaimRef(a.(*v1alpha1.IPClaimRef), b.(*core.IPClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPClaimRef)(nil), (*v1alpha1.IPClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPClaimRef_To_v1alpha1_IPClaimRef(a.(*core.IPClaimRef), b.(*v1alpha1.IPClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPList)(nil), (*core.IPList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPList_To_core_IPList(a.(*v1alpha1.IPList), b.(*core.IPList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPList)(nil), (*v1alpha1.IPList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPList_To_v1alpha1_IPList(a.(*core.IPList), b.(*v1alpha1.IPList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPSpec)(nil), (*core.IPSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPSpec_To_core_IPSpec(a.(*v1alpha1.IPSpec), b.(*core.IPSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPSpec)(nil), (*v1alpha1.IPSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPSpec_To_v1alpha1_IPSpec(a.(*core.IPSpec), b.(*v1alpha1.IPSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.IPStatus)(nil), (*core.IPStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_IPStatus_To_core_IPStatus(a.(*v1alpha1.IPStatus), b.(*core.IPStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.IPStatus)(nil), (*v1alpha1.IPStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_IPStatus_To_v1alpha1_IPStatus(a.(*core.IPStatus), b.(*v1alpha1.IPStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.Instance)(nil), (*core.Instance)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Instance_To_core_Instance(a.(*v1alpha1.Instance), b.(*core.Instance), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.Instance)(nil), (*v1alpha1.Instance)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_Instance_To_v1alpha1_Instance(a.(*core.Instance), b.(*v1alpha1.Instance), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceAffinityTerm)(nil), (*core.InstanceAffinityTerm)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceAffinityTerm_To_core_InstanceAffinityTerm(a.(*v1alpha1.InstanceAffinityTerm), b.(*core.InstanceAffinityTerm), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceAffinityTerm)(nil), (*v1alpha1.InstanceAffinityTerm)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceAffinityTerm_To_v1alpha1_InstanceAffinityTerm(a.(*core.InstanceAffinityTerm), b.(*v1alpha1.InstanceAffinityTerm), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceAntiAffinity)(nil), (*core.InstanceAntiAffinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceAntiAffinity_To_core_InstanceAntiAffinity(a.(*v1alpha1.InstanceAntiAffinity), b.(*core.InstanceAntiAffinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceAntiAffinity)(nil), (*v1alpha1.InstanceAntiAffinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceAntiAffinity_To_v1alpha1_InstanceAntiAffinity(a.(*core.InstanceAntiAffinity), b.(*v1alpha1.InstanceAntiAffinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceList)(nil), (*core.InstanceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceList_To_core_InstanceList(a.(*v1alpha1.InstanceList), b.(*core.InstanceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceList)(nil), (*v1alpha1.InstanceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceList_To_v1alpha1_InstanceList(a.(*core.InstanceList), b.(*v1alpha1.InstanceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceSpec)(nil), (*core.InstanceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceSpec_To_core_InstanceSpec(a.(*v1alpha1.InstanceSpec), b.(*core.InstanceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceSpec)(nil), (*v1alpha1.InstanceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceSpec_To_v1alpha1_InstanceSpec(a.(*core.InstanceSpec), b.(*v1alpha1.InstanceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceStatus)(nil), (*core.InstanceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceStatus_To_core_InstanceStatus(a.(*v1alpha1.InstanceStatus), b.(*core.InstanceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceStatus)(nil), (*v1alpha1.InstanceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceStatus_To_v1alpha1_InstanceStatus(a.(*core.InstanceStatus), b.(*v1alpha1.InstanceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.InstanceTemplate)(nil), (*core.InstanceTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(a.(*v1alpha1.InstanceTemplate), b.(*core.InstanceTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.InstanceTemplate)(nil), (*v1alpha1.InstanceTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(a.(*core.InstanceTemplate), b.(*v1alpha1.InstanceTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancer)(nil), (*core.LoadBalancer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancer_To_core_LoadBalancer(a.(*v1alpha1.LoadBalancer), b.(*core.LoadBalancer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancer)(nil), (*v1alpha1.LoadBalancer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancer_To_v1alpha1_LoadBalancer(a.(*core.LoadBalancer), b.(*v1alpha1.LoadBalancer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerDestination)(nil), (*core.LoadBalancerDestination)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerDestination_To_core_LoadBalancerDestination(a.(*v1alpha1.LoadBalancerDestination), b.(*core.LoadBalancerDestination), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerDestination)(nil), (*v1alpha1.LoadBalancerDestination)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerDestination_To_v1alpha1_LoadBalancerDestination(a.(*core.LoadBalancerDestination), b.(*v1alpha1.LoadBalancerDestination), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerIP)(nil), (*core.LoadBalancerIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerIP_To_core_LoadBalancerIP(a.(*v1alpha1.LoadBalancerIP), b.(*core.LoadBalancerIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerIP)(nil), (*v1alpha1.LoadBalancerIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerIP_To_v1alpha1_LoadBalancerIP(a.(*core.LoadBalancerIP), b.(*v1alpha1.LoadBalancerIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerList)(nil), (*core.LoadBalancerList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerList_To_core_LoadBalancerList(a.(*v1alpha1.LoadBalancerList), b.(*core.LoadBalancerList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerList)(nil), (*v1alpha1.LoadBalancerList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerList_To_v1alpha1_LoadBalancerList(a.(*core.LoadBalancerList), b.(*v1alpha1.LoadBalancerList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerPort)(nil), (*core.LoadBalancerPort)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerPort_To_core_LoadBalancerPort(a.(*v1alpha1.LoadBalancerPort), b.(*core.LoadBalancerPort), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerPort)(nil), (*v1alpha1.LoadBalancerPort)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerPort_To_v1alpha1_LoadBalancerPort(a.(*core.LoadBalancerPort), b.(*v1alpha1.LoadBalancerPort), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerRouting)(nil), (*core.LoadBalancerRouting)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerRouting_To_core_LoadBalancerRouting(a.(*v1alpha1.LoadBalancerRouting), b.(*core.LoadBalancerRouting), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerRouting)(nil), (*v1alpha1.LoadBalancerRouting)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerRouting_To_v1alpha1_LoadBalancerRouting(a.(*core.LoadBalancerRouting), b.(*v1alpha1.LoadBalancerRouting), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerRoutingList)(nil), (*core.LoadBalancerRoutingList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerRoutingList_To_core_LoadBalancerRoutingList(a.(*v1alpha1.LoadBalancerRoutingList), b.(*core.LoadBalancerRoutingList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerRoutingList)(nil), (*v1alpha1.LoadBalancerRoutingList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerRoutingList_To_v1alpha1_LoadBalancerRoutingList(a.(*core.LoadBalancerRoutingList), b.(*v1alpha1.LoadBalancerRoutingList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerSpec)(nil), (*core.LoadBalancerSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec(a.(*v1alpha1.LoadBalancerSpec), b.(*core.LoadBalancerSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerSpec)(nil), (*v1alpha1.LoadBalancerSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec(a.(*core.LoadBalancerSpec), b.(*v1alpha1.LoadBalancerSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerStatus)(nil), (*core.LoadBalancerStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus(a.(*v1alpha1.LoadBalancerStatus), b.(*core.LoadBalancerStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerStatus)(nil), (*v1alpha1.LoadBalancerStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus(a.(*core.LoadBalancerStatus), b.(*v1alpha1.LoadBalancerStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.LoadBalancerTargetRef)(nil), (*core.LoadBalancerTargetRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_LoadBalancerTargetRef_To_core_LoadBalancerTargetRef(a.(*v1alpha1.LoadBalancerTargetRef), b.(*core.LoadBalancerTargetRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.LoadBalancerTargetRef)(nil), (*v1alpha1.LoadBalancerTargetRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_LoadBalancerTargetRef_To_v1alpha1_LoadBalancerTargetRef(a.(*core.LoadBalancerTargetRef), b.(*v1alpha1.LoadBalancerTargetRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGateway)(nil), (*core.NATGateway)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGateway_To_core_NATGateway(a.(*v1alpha1.NATGateway), b.(*core.NATGateway), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGateway)(nil), (*v1alpha1.NATGateway)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGateway_To_v1alpha1_NATGateway(a.(*core.NATGateway), b.(*v1alpha1.NATGateway), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayAutoscaler)(nil), (*core.NATGatewayAutoscaler)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayAutoscaler_To_core_NATGatewayAutoscaler(a.(*v1alpha1.NATGatewayAutoscaler), b.(*core.NATGatewayAutoscaler), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayAutoscaler)(nil), (*v1alpha1.NATGatewayAutoscaler)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayAutoscaler_To_v1alpha1_NATGatewayAutoscaler(a.(*core.NATGatewayAutoscaler), b.(*v1alpha1.NATGatewayAutoscaler), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayAutoscalerList)(nil), (*core.NATGatewayAutoscalerList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayAutoscalerList_To_core_NATGatewayAutoscalerList(a.(*v1alpha1.NATGatewayAutoscalerList), b.(*core.NATGatewayAutoscalerList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayAutoscalerList)(nil), (*v1alpha1.NATGatewayAutoscalerList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayAutoscalerList_To_v1alpha1_NATGatewayAutoscalerList(a.(*core.NATGatewayAutoscalerList), b.(*v1alpha1.NATGatewayAutoscalerList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayAutoscalerSpec)(nil), (*core.NATGatewayAutoscalerSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec(a.(*v1alpha1.NATGatewayAutoscalerSpec), b.(*core.NATGatewayAutoscalerSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayAutoscalerSpec)(nil), (*v1alpha1.NATGatewayAutoscalerSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec(a.(*core.NATGatewayAutoscalerSpec), b.(*v1alpha1.NATGatewayAutoscalerSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayAutoscalerStatus)(nil), (*core.NATGatewayAutoscalerStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus(a.(*v1alpha1.NATGatewayAutoscalerStatus), b.(*core.NATGatewayAutoscalerStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayAutoscalerStatus)(nil), (*v1alpha1.NATGatewayAutoscalerStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus(a.(*core.NATGatewayAutoscalerStatus), b.(*v1alpha1.NATGatewayAutoscalerStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayIP)(nil), (*core.NATGatewayIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayIP_To_core_NATGatewayIP(a.(*v1alpha1.NATGatewayIP), b.(*core.NATGatewayIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayIP)(nil), (*v1alpha1.NATGatewayIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayIP_To_v1alpha1_NATGatewayIP(a.(*core.NATGatewayIP), b.(*v1alpha1.NATGatewayIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayList)(nil), (*core.NATGatewayList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayList_To_core_NATGatewayList(a.(*v1alpha1.NATGatewayList), b.(*core.NATGatewayList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayList)(nil), (*v1alpha1.NATGatewayList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayList_To_v1alpha1_NATGatewayList(a.(*core.NATGatewayList), b.(*v1alpha1.NATGatewayList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewaySpec)(nil), (*core.NATGatewaySpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec(a.(*v1alpha1.NATGatewaySpec), b.(*core.NATGatewaySpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewaySpec)(nil), (*v1alpha1.NATGatewaySpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec(a.(*core.NATGatewaySpec), b.(*v1alpha1.NATGatewaySpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATGatewayStatus)(nil), (*core.NATGatewayStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus(a.(*v1alpha1.NATGatewayStatus), b.(*core.NATGatewayStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATGatewayStatus)(nil), (*v1alpha1.NATGatewayStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus(a.(*core.NATGatewayStatus), b.(*v1alpha1.NATGatewayStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATIP)(nil), (*core.NATIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATIP_To_core_NATIP(a.(*v1alpha1.NATIP), b.(*core.NATIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATIP)(nil), (*v1alpha1.NATIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATIP_To_v1alpha1_NATIP(a.(*core.NATIP), b.(*v1alpha1.NATIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATIPSection)(nil), (*core.NATIPSection)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATIPSection_To_core_NATIPSection(a.(*v1alpha1.NATIPSection), b.(*core.NATIPSection), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATIPSection)(nil), (*v1alpha1.NATIPSection)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATIPSection_To_v1alpha1_NATIPSection(a.(*core.NATIPSection), b.(*v1alpha1.NATIPSection), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATTable)(nil), (*core.NATTable)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATTable_To_core_NATTable(a.(*v1alpha1.NATTable), b.(*core.NATTable), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATTable)(nil), (*v1alpha1.NATTable)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATTable_To_v1alpha1_NATTable(a.(*core.NATTable), b.(*v1alpha1.NATTable), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATTableIPTargetRef)(nil), (*core.NATTableIPTargetRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATTableIPTargetRef_To_core_NATTableIPTargetRef(a.(*v1alpha1.NATTableIPTargetRef), b.(*core.NATTableIPTargetRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATTableIPTargetRef)(nil), (*v1alpha1.NATTableIPTargetRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATTableIPTargetRef_To_v1alpha1_NATTableIPTargetRef(a.(*core.NATTableIPTargetRef), b.(*v1alpha1.NATTableIPTargetRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NATTableList)(nil), (*core.NATTableList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NATTableList_To_core_NATTableList(a.(*v1alpha1.NATTableList), b.(*core.NATTableList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NATTableList)(nil), (*v1alpha1.NATTableList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NATTableList_To_v1alpha1_NATTableList(a.(*core.NATTableList), b.(*v1alpha1.NATTableList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.Network)(nil), (*core.Network)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Network_To_core_Network(a.(*v1alpha1.Network), b.(*core.Network), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.Network)(nil), (*v1alpha1.Network)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_Network_To_v1alpha1_Network(a.(*core.Network), b.(*v1alpha1.Network), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkID)(nil), (*core.NetworkID)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkID_To_core_NetworkID(a.(*v1alpha1.NetworkID), b.(*core.NetworkID), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkID)(nil), (*v1alpha1.NetworkID)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkID_To_v1alpha1_NetworkID(a.(*core.NetworkID), b.(*v1alpha1.NetworkID), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkIDClaimRef)(nil), (*core.NetworkIDClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef(a.(*v1alpha1.NetworkIDClaimRef), b.(*core.NetworkIDClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkIDClaimRef)(nil), (*v1alpha1.NetworkIDClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef(a.(*core.NetworkIDClaimRef), b.(*v1alpha1.NetworkIDClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkIDList)(nil), (*core.NetworkIDList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkIDList_To_core_NetworkIDList(a.(*v1alpha1.NetworkIDList), b.(*core.NetworkIDList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkIDList)(nil), (*v1alpha1.NetworkIDList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkIDList_To_v1alpha1_NetworkIDList(a.(*core.NetworkIDList), b.(*v1alpha1.NetworkIDList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkIDSpec)(nil), (*core.NetworkIDSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec(a.(*v1alpha1.NetworkIDSpec), b.(*core.NetworkIDSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkIDSpec)(nil), (*v1alpha1.NetworkIDSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec(a.(*core.NetworkIDSpec), b.(*v1alpha1.NetworkIDSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterface)(nil), (*core.NetworkInterface)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterface_To_core_NetworkInterface(a.(*v1alpha1.NetworkInterface), b.(*core.NetworkInterface), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterface)(nil), (*v1alpha1.NetworkInterface)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterface_To_v1alpha1_NetworkInterface(a.(*core.NetworkInterface), b.(*v1alpha1.NetworkInterface), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfaceList)(nil), (*core.NetworkInterfaceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfaceList_To_core_NetworkInterfaceList(a.(*v1alpha1.NetworkInterfaceList), b.(*core.NetworkInterfaceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfaceList)(nil), (*v1alpha1.NetworkInterfaceList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfaceList_To_v1alpha1_NetworkInterfaceList(a.(*core.NetworkInterfaceList), b.(*v1alpha1.NetworkInterfaceList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfaceNAT)(nil), (*core.NetworkInterfaceNAT)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfaceNAT_To_core_NetworkInterfaceNAT(a.(*v1alpha1.NetworkInterfaceNAT), b.(*core.NetworkInterfaceNAT), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfaceNAT)(nil), (*v1alpha1.NetworkInterfaceNAT)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfaceNAT_To_v1alpha1_NetworkInterfaceNAT(a.(*core.NetworkInterfaceNAT), b.(*v1alpha1.NetworkInterfaceNAT), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfaceNATClaimRef)(nil), (*core.NetworkInterfaceNATClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef(a.(*v1alpha1.NetworkInterfaceNATClaimRef), b.(*core.NetworkInterfaceNATClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfaceNATClaimRef)(nil), (*v1alpha1.NetworkInterfaceNATClaimRef)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef(a.(*core.NetworkInterfaceNATClaimRef), b.(*v1alpha1.NetworkInterfaceNATClaimRef), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfacePublicIP)(nil), (*core.NetworkInterfacePublicIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfacePublicIP_To_core_NetworkInterfacePublicIP(a.(*v1alpha1.NetworkInterfacePublicIP), b.(*core.NetworkInterfacePublicIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfacePublicIP)(nil), (*v1alpha1.NetworkInterfacePublicIP)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfacePublicIP_To_v1alpha1_NetworkInterfacePublicIP(a.(*core.NetworkInterfacePublicIP), b.(*v1alpha1.NetworkInterfacePublicIP), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfaceSpec)(nil), (*core.NetworkInterfaceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec(a.(*v1alpha1.NetworkInterfaceSpec), b.(*core.NetworkInterfaceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfaceSpec)(nil), (*v1alpha1.NetworkInterfaceSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec(a.(*core.NetworkInterfaceSpec), b.(*v1alpha1.NetworkInterfaceSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkInterfaceStatus)(nil), (*core.NetworkInterfaceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus(a.(*v1alpha1.NetworkInterfaceStatus), b.(*core.NetworkInterfaceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkInterfaceStatus)(nil), (*v1alpha1.NetworkInterfaceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus(a.(*core.NetworkInterfaceStatus), b.(*v1alpha1.NetworkInterfaceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkList)(nil), (*core.NetworkList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkList_To_core_NetworkList(a.(*v1alpha1.NetworkList), b.(*core.NetworkList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkList)(nil), (*v1alpha1.NetworkList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkList_To_v1alpha1_NetworkList(a.(*core.NetworkList), b.(*v1alpha1.NetworkList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkSpec)(nil), (*core.NetworkSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkSpec_To_core_NetworkSpec(a.(*v1alpha1.NetworkSpec), b.(*core.NetworkSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkSpec)(nil), (*v1alpha1.NetworkSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkSpec_To_v1alpha1_NetworkSpec(a.(*core.NetworkSpec), b.(*v1alpha1.NetworkSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NetworkStatus)(nil), (*core.NetworkStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NetworkStatus_To_core_NetworkStatus(a.(*v1alpha1.NetworkStatus), b.(*core.NetworkStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NetworkStatus)(nil), (*v1alpha1.NetworkStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NetworkStatus_To_v1alpha1_NetworkStatus(a.(*core.NetworkStatus), b.(*v1alpha1.NetworkStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.Node)(nil), (*core.Node)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Node_To_core_Node(a.(*v1alpha1.Node), b.(*core.Node), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.Node)(nil), (*v1alpha1.Node)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_Node_To_v1alpha1_Node(a.(*core.Node), b.(*v1alpha1.Node), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeAffinity)(nil), (*core.NodeAffinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeAffinity_To_core_NodeAffinity(a.(*v1alpha1.NodeAffinity), b.(*core.NodeAffinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeAffinity)(nil), (*v1alpha1.NodeAffinity)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeAffinity_To_v1alpha1_NodeAffinity(a.(*core.NodeAffinity), b.(*v1alpha1.NodeAffinity), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeList)(nil), (*core.NodeList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeList_To_core_NodeList(a.(*v1alpha1.NodeList), b.(*core.NodeList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeList)(nil), (*v1alpha1.NodeList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeList_To_v1alpha1_NodeList(a.(*core.NodeList), b.(*v1alpha1.NodeList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeSelector)(nil), (*core.NodeSelector)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeSelector_To_core_NodeSelector(a.(*v1alpha1.NodeSelector), b.(*core.NodeSelector), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeSelector)(nil), (*v1alpha1.NodeSelector)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeSelector_To_v1alpha1_NodeSelector(a.(*core.NodeSelector), b.(*v1alpha1.NodeSelector), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeSelectorRequirement)(nil), (*core.NodeSelectorRequirement)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeSelectorRequirement_To_core_NodeSelectorRequirement(a.(*v1alpha1.NodeSelectorRequirement), b.(*core.NodeSelectorRequirement), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeSelectorRequirement)(nil), (*v1alpha1.NodeSelectorRequirement)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeSelectorRequirement_To_v1alpha1_NodeSelectorRequirement(a.(*core.NodeSelectorRequirement), b.(*v1alpha1.NodeSelectorRequirement), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeSelectorTerm)(nil), (*core.NodeSelectorTerm)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeSelectorTerm_To_core_NodeSelectorTerm(a.(*v1alpha1.NodeSelectorTerm), b.(*core.NodeSelectorTerm), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeSelectorTerm)(nil), (*v1alpha1.NodeSelectorTerm)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeSelectorTerm_To_v1alpha1_NodeSelectorTerm(a.(*core.NodeSelectorTerm), b.(*v1alpha1.NodeSelectorTerm), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeSpec)(nil), (*core.NodeSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeSpec_To_core_NodeSpec(a.(*v1alpha1.NodeSpec), b.(*core.NodeSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeSpec)(nil), (*v1alpha1.NodeSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeSpec_To_v1alpha1_NodeSpec(a.(*core.NodeSpec), b.(*v1alpha1.NodeSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.NodeStatus)(nil), (*core.NodeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_NodeStatus_To_core_NodeStatus(a.(*v1alpha1.NodeStatus), b.(*core.NodeStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.NodeStatus)(nil), (*v1alpha1.NodeStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_NodeStatus_To_v1alpha1_NodeStatus(a.(*core.NodeStatus), b.(*v1alpha1.NodeStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.PCIAddress)(nil), (*core.PCIAddress)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_PCIAddress_To_core_PCIAddress(a.(*v1alpha1.PCIAddress), b.(*core.PCIAddress), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.PCIAddress)(nil), (*v1alpha1.PCIAddress)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_PCIAddress_To_v1alpha1_PCIAddress(a.(*core.PCIAddress), b.(*v1alpha1.PCIAddress), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1alpha1.TopologySpreadConstraint)(nil), (*core.TopologySpreadConstraint)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_TopologySpreadConstraint_To_core_TopologySpreadConstraint(a.(*v1alpha1.TopologySpreadConstraint), b.(*core.TopologySpreadConstraint), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*core.TopologySpreadConstraint)(nil), (*v1alpha1.TopologySpreadConstraint)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_core_TopologySpreadConstraint_To_v1alpha1_TopologySpreadConstraint(a.(*core.TopologySpreadConstraint), b.(*v1alpha1.TopologySpreadConstraint), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_Affinity_To_core_Affinity(in *v1alpha1.Affinity, out *core.Affinity, s conversion.Scope) error { + out.NodeAffinity = (*core.NodeAffinity)(unsafe.Pointer(in.NodeAffinity)) + out.InstanceAntiAffinity = (*core.InstanceAntiAffinity)(unsafe.Pointer(in.InstanceAntiAffinity)) + return nil +} + +// Convert_v1alpha1_Affinity_To_core_Affinity is an autogenerated conversion function. +func Convert_v1alpha1_Affinity_To_core_Affinity(in *v1alpha1.Affinity, out *core.Affinity, s conversion.Scope) error { + return autoConvert_v1alpha1_Affinity_To_core_Affinity(in, out, s) +} + +func autoConvert_core_Affinity_To_v1alpha1_Affinity(in *core.Affinity, out *v1alpha1.Affinity, s conversion.Scope) error { + out.NodeAffinity = (*v1alpha1.NodeAffinity)(unsafe.Pointer(in.NodeAffinity)) + out.InstanceAntiAffinity = (*v1alpha1.InstanceAntiAffinity)(unsafe.Pointer(in.InstanceAntiAffinity)) + return nil +} + +// Convert_core_Affinity_To_v1alpha1_Affinity is an autogenerated conversion function. +func Convert_core_Affinity_To_v1alpha1_Affinity(in *core.Affinity, out *v1alpha1.Affinity, s conversion.Scope) error { + return autoConvert_core_Affinity_To_v1alpha1_Affinity(in, out, s) +} + +func autoConvert_v1alpha1_DaemonSet_To_core_DaemonSet(in *v1alpha1.DaemonSet, out *core.DaemonSet, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_DaemonSet_To_core_DaemonSet is an autogenerated conversion function. +func Convert_v1alpha1_DaemonSet_To_core_DaemonSet(in *v1alpha1.DaemonSet, out *core.DaemonSet, s conversion.Scope) error { + return autoConvert_v1alpha1_DaemonSet_To_core_DaemonSet(in, out, s) +} + +func autoConvert_core_DaemonSet_To_v1alpha1_DaemonSet(in *core.DaemonSet, out *v1alpha1.DaemonSet, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_DaemonSet_To_v1alpha1_DaemonSet is an autogenerated conversion function. +func Convert_core_DaemonSet_To_v1alpha1_DaemonSet(in *core.DaemonSet, out *v1alpha1.DaemonSet, s conversion.Scope) error { + return autoConvert_core_DaemonSet_To_v1alpha1_DaemonSet(in, out, s) +} + +func autoConvert_v1alpha1_DaemonSetList_To_core_DaemonSetList(in *v1alpha1.DaemonSetList, out *core.DaemonSetList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.DaemonSet)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_DaemonSetList_To_core_DaemonSetList is an autogenerated conversion function. +func Convert_v1alpha1_DaemonSetList_To_core_DaemonSetList(in *v1alpha1.DaemonSetList, out *core.DaemonSetList, s conversion.Scope) error { + return autoConvert_v1alpha1_DaemonSetList_To_core_DaemonSetList(in, out, s) +} + +func autoConvert_core_DaemonSetList_To_v1alpha1_DaemonSetList(in *core.DaemonSetList, out *v1alpha1.DaemonSetList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.DaemonSet)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_DaemonSetList_To_v1alpha1_DaemonSetList is an autogenerated conversion function. +func Convert_core_DaemonSetList_To_v1alpha1_DaemonSetList(in *core.DaemonSetList, out *v1alpha1.DaemonSetList, s conversion.Scope) error { + return autoConvert_core_DaemonSetList_To_v1alpha1_DaemonSetList(in, out, s) +} + +func autoConvert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec(in *v1alpha1.DaemonSetSpec, out *core.DaemonSetSpec, s conversion.Scope) error { + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + if err := Convert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec is an autogenerated conversion function. +func Convert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec(in *v1alpha1.DaemonSetSpec, out *core.DaemonSetSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_DaemonSetSpec_To_core_DaemonSetSpec(in, out, s) +} + +func autoConvert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec(in *core.DaemonSetSpec, out *v1alpha1.DaemonSetSpec, s conversion.Scope) error { + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + if err := Convert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec is an autogenerated conversion function. +func Convert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec(in *core.DaemonSetSpec, out *v1alpha1.DaemonSetSpec, s conversion.Scope) error { + return autoConvert_core_DaemonSetSpec_To_v1alpha1_DaemonSetSpec(in, out, s) +} + +func autoConvert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus(in *v1alpha1.DaemonSetStatus, out *core.DaemonSetStatus, s conversion.Scope) error { + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + return nil +} + +// Convert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus is an autogenerated conversion function. +func Convert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus(in *v1alpha1.DaemonSetStatus, out *core.DaemonSetStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_DaemonSetStatus_To_core_DaemonSetStatus(in, out, s) +} + +func autoConvert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus(in *core.DaemonSetStatus, out *v1alpha1.DaemonSetStatus, s conversion.Scope) error { + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + return nil +} + +// Convert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus is an autogenerated conversion function. +func Convert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus(in *core.DaemonSetStatus, out *v1alpha1.DaemonSetStatus, s conversion.Scope) error { + return autoConvert_core_DaemonSetStatus_To_v1alpha1_DaemonSetStatus(in, out, s) +} + +func autoConvert_v1alpha1_IP_To_core_IP(in *v1alpha1.IP, out *core.IP, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_IPSpec_To_core_IPSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_IPStatus_To_core_IPStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_IP_To_core_IP is an autogenerated conversion function. +func Convert_v1alpha1_IP_To_core_IP(in *v1alpha1.IP, out *core.IP, s conversion.Scope) error { + return autoConvert_v1alpha1_IP_To_core_IP(in, out, s) +} + +func autoConvert_core_IP_To_v1alpha1_IP(in *core.IP, out *v1alpha1.IP, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_IPSpec_To_v1alpha1_IPSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_IPStatus_To_v1alpha1_IPStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_IP_To_v1alpha1_IP is an autogenerated conversion function. +func Convert_core_IP_To_v1alpha1_IP(in *core.IP, out *v1alpha1.IP, s conversion.Scope) error { + return autoConvert_core_IP_To_v1alpha1_IP(in, out, s) +} + +func autoConvert_v1alpha1_IPAddress_To_core_IPAddress(in *v1alpha1.IPAddress, out *core.IPAddress, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_IPAddress_To_core_IPAddress is an autogenerated conversion function. +func Convert_v1alpha1_IPAddress_To_core_IPAddress(in *v1alpha1.IPAddress, out *core.IPAddress, s conversion.Scope) error { + return autoConvert_v1alpha1_IPAddress_To_core_IPAddress(in, out, s) +} + +func autoConvert_core_IPAddress_To_v1alpha1_IPAddress(in *core.IPAddress, out *v1alpha1.IPAddress, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_core_IPAddress_To_v1alpha1_IPAddress is an autogenerated conversion function. +func Convert_core_IPAddress_To_v1alpha1_IPAddress(in *core.IPAddress, out *v1alpha1.IPAddress, s conversion.Scope) error { + return autoConvert_core_IPAddress_To_v1alpha1_IPAddress(in, out, s) +} + +func autoConvert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef(in *v1alpha1.IPAddressClaimRef, out *core.IPAddressClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Namespace = in.Namespace + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef is an autogenerated conversion function. +func Convert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef(in *v1alpha1.IPAddressClaimRef, out *core.IPAddressClaimRef, s conversion.Scope) error { + return autoConvert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef(in, out, s) +} + +func autoConvert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef(in *core.IPAddressClaimRef, out *v1alpha1.IPAddressClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Namespace = in.Namespace + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef is an autogenerated conversion function. +func Convert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef(in *core.IPAddressClaimRef, out *v1alpha1.IPAddressClaimRef, s conversion.Scope) error { + return autoConvert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef(in, out, s) +} + +func autoConvert_v1alpha1_IPAddressList_To_core_IPAddressList(in *v1alpha1.IPAddressList, out *core.IPAddressList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.IPAddress)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_IPAddressList_To_core_IPAddressList is an autogenerated conversion function. +func Convert_v1alpha1_IPAddressList_To_core_IPAddressList(in *v1alpha1.IPAddressList, out *core.IPAddressList, s conversion.Scope) error { + return autoConvert_v1alpha1_IPAddressList_To_core_IPAddressList(in, out, s) +} + +func autoConvert_core_IPAddressList_To_v1alpha1_IPAddressList(in *core.IPAddressList, out *v1alpha1.IPAddressList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.IPAddress)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_IPAddressList_To_v1alpha1_IPAddressList is an autogenerated conversion function. +func Convert_core_IPAddressList_To_v1alpha1_IPAddressList(in *core.IPAddressList, out *v1alpha1.IPAddressList, s conversion.Scope) error { + return autoConvert_core_IPAddressList_To_v1alpha1_IPAddressList(in, out, s) +} + +func autoConvert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec(in *v1alpha1.IPAddressSpec, out *core.IPAddressSpec, s conversion.Scope) error { + out.IP = in.IP + if err := Convert_v1alpha1_IPAddressClaimRef_To_core_IPAddressClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec is an autogenerated conversion function. +func Convert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec(in *v1alpha1.IPAddressSpec, out *core.IPAddressSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_IPAddressSpec_To_core_IPAddressSpec(in, out, s) +} + +func autoConvert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec(in *core.IPAddressSpec, out *v1alpha1.IPAddressSpec, s conversion.Scope) error { + out.IP = in.IP + if err := Convert_core_IPAddressClaimRef_To_v1alpha1_IPAddressClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec is an autogenerated conversion function. +func Convert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec(in *core.IPAddressSpec, out *v1alpha1.IPAddressSpec, s conversion.Scope) error { + return autoConvert_core_IPAddressSpec_To_v1alpha1_IPAddressSpec(in, out, s) +} + +func autoConvert_v1alpha1_IPClaimRef_To_core_IPClaimRef(in *v1alpha1.IPClaimRef, out *core.IPClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_v1alpha1_IPClaimRef_To_core_IPClaimRef is an autogenerated conversion function. +func Convert_v1alpha1_IPClaimRef_To_core_IPClaimRef(in *v1alpha1.IPClaimRef, out *core.IPClaimRef, s conversion.Scope) error { + return autoConvert_v1alpha1_IPClaimRef_To_core_IPClaimRef(in, out, s) +} + +func autoConvert_core_IPClaimRef_To_v1alpha1_IPClaimRef(in *core.IPClaimRef, out *v1alpha1.IPClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_core_IPClaimRef_To_v1alpha1_IPClaimRef is an autogenerated conversion function. +func Convert_core_IPClaimRef_To_v1alpha1_IPClaimRef(in *core.IPClaimRef, out *v1alpha1.IPClaimRef, s conversion.Scope) error { + return autoConvert_core_IPClaimRef_To_v1alpha1_IPClaimRef(in, out, s) +} + +func autoConvert_v1alpha1_IPList_To_core_IPList(in *v1alpha1.IPList, out *core.IPList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.IP)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_IPList_To_core_IPList is an autogenerated conversion function. +func Convert_v1alpha1_IPList_To_core_IPList(in *v1alpha1.IPList, out *core.IPList, s conversion.Scope) error { + return autoConvert_v1alpha1_IPList_To_core_IPList(in, out, s) +} + +func autoConvert_core_IPList_To_v1alpha1_IPList(in *core.IPList, out *v1alpha1.IPList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.IP)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_IPList_To_v1alpha1_IPList is an autogenerated conversion function. +func Convert_core_IPList_To_v1alpha1_IPList(in *core.IPList, out *v1alpha1.IPList, s conversion.Scope) error { + return autoConvert_core_IPList_To_v1alpha1_IPList(in, out, s) +} + +func autoConvert_v1alpha1_IPSpec_To_core_IPSpec(in *v1alpha1.IPSpec, out *core.IPSpec, s conversion.Scope) error { + out.Type = core.IPType(in.Type) + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + out.ClaimRef = (*core.IPClaimRef)(unsafe.Pointer(in.ClaimRef)) + return nil +} + +// Convert_v1alpha1_IPSpec_To_core_IPSpec is an autogenerated conversion function. +func Convert_v1alpha1_IPSpec_To_core_IPSpec(in *v1alpha1.IPSpec, out *core.IPSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_IPSpec_To_core_IPSpec(in, out, s) +} + +func autoConvert_core_IPSpec_To_v1alpha1_IPSpec(in *core.IPSpec, out *v1alpha1.IPSpec, s conversion.Scope) error { + out.Type = v1alpha1.IPType(in.Type) + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + out.ClaimRef = (*v1alpha1.IPClaimRef)(unsafe.Pointer(in.ClaimRef)) + return nil +} + +// Convert_core_IPSpec_To_v1alpha1_IPSpec is an autogenerated conversion function. +func Convert_core_IPSpec_To_v1alpha1_IPSpec(in *core.IPSpec, out *v1alpha1.IPSpec, s conversion.Scope) error { + return autoConvert_core_IPSpec_To_v1alpha1_IPSpec(in, out, s) +} + +func autoConvert_v1alpha1_IPStatus_To_core_IPStatus(in *v1alpha1.IPStatus, out *core.IPStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_IPStatus_To_core_IPStatus is an autogenerated conversion function. +func Convert_v1alpha1_IPStatus_To_core_IPStatus(in *v1alpha1.IPStatus, out *core.IPStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_IPStatus_To_core_IPStatus(in, out, s) +} + +func autoConvert_core_IPStatus_To_v1alpha1_IPStatus(in *core.IPStatus, out *v1alpha1.IPStatus, s conversion.Scope) error { + return nil +} + +// Convert_core_IPStatus_To_v1alpha1_IPStatus is an autogenerated conversion function. +func Convert_core_IPStatus_To_v1alpha1_IPStatus(in *core.IPStatus, out *v1alpha1.IPStatus, s conversion.Scope) error { + return autoConvert_core_IPStatus_To_v1alpha1_IPStatus(in, out, s) +} + +func autoConvert_v1alpha1_Instance_To_core_Instance(in *v1alpha1.Instance, out *core.Instance, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_InstanceSpec_To_core_InstanceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_InstanceStatus_To_core_InstanceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_Instance_To_core_Instance is an autogenerated conversion function. +func Convert_v1alpha1_Instance_To_core_Instance(in *v1alpha1.Instance, out *core.Instance, s conversion.Scope) error { + return autoConvert_v1alpha1_Instance_To_core_Instance(in, out, s) +} + +func autoConvert_core_Instance_To_v1alpha1_Instance(in *core.Instance, out *v1alpha1.Instance, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_InstanceSpec_To_v1alpha1_InstanceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_InstanceStatus_To_v1alpha1_InstanceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_Instance_To_v1alpha1_Instance is an autogenerated conversion function. +func Convert_core_Instance_To_v1alpha1_Instance(in *core.Instance, out *v1alpha1.Instance, s conversion.Scope) error { + return autoConvert_core_Instance_To_v1alpha1_Instance(in, out, s) +} + +func autoConvert_v1alpha1_InstanceAffinityTerm_To_core_InstanceAffinityTerm(in *v1alpha1.InstanceAffinityTerm, out *core.InstanceAffinityTerm, s conversion.Scope) error { + out.LabelSelector = (*v1.LabelSelector)(unsafe.Pointer(in.LabelSelector)) + out.TopologyKey = in.TopologyKey + return nil +} + +// Convert_v1alpha1_InstanceAffinityTerm_To_core_InstanceAffinityTerm is an autogenerated conversion function. +func Convert_v1alpha1_InstanceAffinityTerm_To_core_InstanceAffinityTerm(in *v1alpha1.InstanceAffinityTerm, out *core.InstanceAffinityTerm, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceAffinityTerm_To_core_InstanceAffinityTerm(in, out, s) +} + +func autoConvert_core_InstanceAffinityTerm_To_v1alpha1_InstanceAffinityTerm(in *core.InstanceAffinityTerm, out *v1alpha1.InstanceAffinityTerm, s conversion.Scope) error { + out.LabelSelector = (*v1.LabelSelector)(unsafe.Pointer(in.LabelSelector)) + out.TopologyKey = in.TopologyKey + return nil +} + +// Convert_core_InstanceAffinityTerm_To_v1alpha1_InstanceAffinityTerm is an autogenerated conversion function. +func Convert_core_InstanceAffinityTerm_To_v1alpha1_InstanceAffinityTerm(in *core.InstanceAffinityTerm, out *v1alpha1.InstanceAffinityTerm, s conversion.Scope) error { + return autoConvert_core_InstanceAffinityTerm_To_v1alpha1_InstanceAffinityTerm(in, out, s) +} + +func autoConvert_v1alpha1_InstanceAntiAffinity_To_core_InstanceAntiAffinity(in *v1alpha1.InstanceAntiAffinity, out *core.InstanceAntiAffinity, s conversion.Scope) error { + out.RequiredDuringSchedulingIgnoredDuringExecution = *(*[]core.InstanceAffinityTerm)(unsafe.Pointer(&in.RequiredDuringSchedulingIgnoredDuringExecution)) + return nil +} + +// Convert_v1alpha1_InstanceAntiAffinity_To_core_InstanceAntiAffinity is an autogenerated conversion function. +func Convert_v1alpha1_InstanceAntiAffinity_To_core_InstanceAntiAffinity(in *v1alpha1.InstanceAntiAffinity, out *core.InstanceAntiAffinity, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceAntiAffinity_To_core_InstanceAntiAffinity(in, out, s) +} + +func autoConvert_core_InstanceAntiAffinity_To_v1alpha1_InstanceAntiAffinity(in *core.InstanceAntiAffinity, out *v1alpha1.InstanceAntiAffinity, s conversion.Scope) error { + out.RequiredDuringSchedulingIgnoredDuringExecution = *(*[]v1alpha1.InstanceAffinityTerm)(unsafe.Pointer(&in.RequiredDuringSchedulingIgnoredDuringExecution)) + return nil +} + +// Convert_core_InstanceAntiAffinity_To_v1alpha1_InstanceAntiAffinity is an autogenerated conversion function. +func Convert_core_InstanceAntiAffinity_To_v1alpha1_InstanceAntiAffinity(in *core.InstanceAntiAffinity, out *v1alpha1.InstanceAntiAffinity, s conversion.Scope) error { + return autoConvert_core_InstanceAntiAffinity_To_v1alpha1_InstanceAntiAffinity(in, out, s) +} + +func autoConvert_v1alpha1_InstanceList_To_core_InstanceList(in *v1alpha1.InstanceList, out *core.InstanceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.Instance)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_InstanceList_To_core_InstanceList is an autogenerated conversion function. +func Convert_v1alpha1_InstanceList_To_core_InstanceList(in *v1alpha1.InstanceList, out *core.InstanceList, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceList_To_core_InstanceList(in, out, s) +} + +func autoConvert_core_InstanceList_To_v1alpha1_InstanceList(in *core.InstanceList, out *v1alpha1.InstanceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.Instance)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_InstanceList_To_v1alpha1_InstanceList is an autogenerated conversion function. +func Convert_core_InstanceList_To_v1alpha1_InstanceList(in *core.InstanceList, out *v1alpha1.InstanceList, s conversion.Scope) error { + return autoConvert_core_InstanceList_To_v1alpha1_InstanceList(in, out, s) +} + +func autoConvert_v1alpha1_InstanceSpec_To_core_InstanceSpec(in *v1alpha1.InstanceSpec, out *core.InstanceSpec, s conversion.Scope) error { + out.Type = core.InstanceType(in.Type) + out.LoadBalancerType = core.LoadBalancerType(in.LoadBalancerType) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.LoadBalancerPorts = *(*[]core.LoadBalancerPort)(unsafe.Pointer(&in.LoadBalancerPorts)) + out.Affinity = (*core.Affinity)(unsafe.Pointer(in.Affinity)) + out.TopologySpreadConstraints = *(*[]core.TopologySpreadConstraint)(unsafe.Pointer(&in.TopologySpreadConstraints)) + out.NodeRef = (*corev1.LocalObjectReference)(unsafe.Pointer(in.NodeRef)) + return nil +} + +// Convert_v1alpha1_InstanceSpec_To_core_InstanceSpec is an autogenerated conversion function. +func Convert_v1alpha1_InstanceSpec_To_core_InstanceSpec(in *v1alpha1.InstanceSpec, out *core.InstanceSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceSpec_To_core_InstanceSpec(in, out, s) +} + +func autoConvert_core_InstanceSpec_To_v1alpha1_InstanceSpec(in *core.InstanceSpec, out *v1alpha1.InstanceSpec, s conversion.Scope) error { + out.Type = v1alpha1.InstanceType(in.Type) + out.LoadBalancerType = v1alpha1.LoadBalancerType(in.LoadBalancerType) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.LoadBalancerPorts = *(*[]v1alpha1.LoadBalancerPort)(unsafe.Pointer(&in.LoadBalancerPorts)) + out.Affinity = (*v1alpha1.Affinity)(unsafe.Pointer(in.Affinity)) + out.TopologySpreadConstraints = *(*[]v1alpha1.TopologySpreadConstraint)(unsafe.Pointer(&in.TopologySpreadConstraints)) + out.NodeRef = (*corev1.LocalObjectReference)(unsafe.Pointer(in.NodeRef)) + return nil +} + +// Convert_core_InstanceSpec_To_v1alpha1_InstanceSpec is an autogenerated conversion function. +func Convert_core_InstanceSpec_To_v1alpha1_InstanceSpec(in *core.InstanceSpec, out *v1alpha1.InstanceSpec, s conversion.Scope) error { + return autoConvert_core_InstanceSpec_To_v1alpha1_InstanceSpec(in, out, s) +} + +func autoConvert_v1alpha1_InstanceStatus_To_core_InstanceStatus(in *v1alpha1.InstanceStatus, out *core.InstanceStatus, s conversion.Scope) error { + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + return nil +} + +// Convert_v1alpha1_InstanceStatus_To_core_InstanceStatus is an autogenerated conversion function. +func Convert_v1alpha1_InstanceStatus_To_core_InstanceStatus(in *v1alpha1.InstanceStatus, out *core.InstanceStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceStatus_To_core_InstanceStatus(in, out, s) +} + +func autoConvert_core_InstanceStatus_To_v1alpha1_InstanceStatus(in *core.InstanceStatus, out *v1alpha1.InstanceStatus, s conversion.Scope) error { + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + return nil +} + +// Convert_core_InstanceStatus_To_v1alpha1_InstanceStatus is an autogenerated conversion function. +func Convert_core_InstanceStatus_To_v1alpha1_InstanceStatus(in *core.InstanceStatus, out *v1alpha1.InstanceStatus, s conversion.Scope) error { + return autoConvert_core_InstanceStatus_To_v1alpha1_InstanceStatus(in, out, s) +} + +func autoConvert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(in *v1alpha1.InstanceTemplate, out *core.InstanceTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_InstanceSpec_To_core_InstanceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate is an autogenerated conversion function. +func Convert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(in *v1alpha1.InstanceTemplate, out *core.InstanceTemplate, s conversion.Scope) error { + return autoConvert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(in, out, s) +} + +func autoConvert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(in *core.InstanceTemplate, out *v1alpha1.InstanceTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_InstanceSpec_To_v1alpha1_InstanceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate is an autogenerated conversion function. +func Convert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(in *core.InstanceTemplate, out *v1alpha1.InstanceTemplate, s conversion.Scope) error { + return autoConvert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancer_To_core_LoadBalancer(in *v1alpha1.LoadBalancer, out *core.LoadBalancer, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_LoadBalancer_To_core_LoadBalancer is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancer_To_core_LoadBalancer(in *v1alpha1.LoadBalancer, out *core.LoadBalancer, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancer_To_core_LoadBalancer(in, out, s) +} + +func autoConvert_core_LoadBalancer_To_v1alpha1_LoadBalancer(in *core.LoadBalancer, out *v1alpha1.LoadBalancer, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_LoadBalancer_To_v1alpha1_LoadBalancer is an autogenerated conversion function. +func Convert_core_LoadBalancer_To_v1alpha1_LoadBalancer(in *core.LoadBalancer, out *v1alpha1.LoadBalancer, s conversion.Scope) error { + return autoConvert_core_LoadBalancer_To_v1alpha1_LoadBalancer(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerDestination_To_core_LoadBalancerDestination(in *v1alpha1.LoadBalancerDestination, out *core.LoadBalancerDestination, s conversion.Scope) error { + out.IP = in.IP + out.TargetRef = (*core.LoadBalancerTargetRef)(unsafe.Pointer(in.TargetRef)) + return nil +} + +// Convert_v1alpha1_LoadBalancerDestination_To_core_LoadBalancerDestination is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerDestination_To_core_LoadBalancerDestination(in *v1alpha1.LoadBalancerDestination, out *core.LoadBalancerDestination, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerDestination_To_core_LoadBalancerDestination(in, out, s) +} + +func autoConvert_core_LoadBalancerDestination_To_v1alpha1_LoadBalancerDestination(in *core.LoadBalancerDestination, out *v1alpha1.LoadBalancerDestination, s conversion.Scope) error { + out.IP = in.IP + out.TargetRef = (*v1alpha1.LoadBalancerTargetRef)(unsafe.Pointer(in.TargetRef)) + return nil +} + +// Convert_core_LoadBalancerDestination_To_v1alpha1_LoadBalancerDestination is an autogenerated conversion function. +func Convert_core_LoadBalancerDestination_To_v1alpha1_LoadBalancerDestination(in *core.LoadBalancerDestination, out *v1alpha1.LoadBalancerDestination, s conversion.Scope) error { + return autoConvert_core_LoadBalancerDestination_To_v1alpha1_LoadBalancerDestination(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerIP_To_core_LoadBalancerIP(in *v1alpha1.LoadBalancerIP, out *core.LoadBalancerIP, s conversion.Scope) error { + out.Name = in.Name + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + return nil +} + +// Convert_v1alpha1_LoadBalancerIP_To_core_LoadBalancerIP is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerIP_To_core_LoadBalancerIP(in *v1alpha1.LoadBalancerIP, out *core.LoadBalancerIP, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerIP_To_core_LoadBalancerIP(in, out, s) +} + +func autoConvert_core_LoadBalancerIP_To_v1alpha1_LoadBalancerIP(in *core.LoadBalancerIP, out *v1alpha1.LoadBalancerIP, s conversion.Scope) error { + out.Name = in.Name + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + return nil +} + +// Convert_core_LoadBalancerIP_To_v1alpha1_LoadBalancerIP is an autogenerated conversion function. +func Convert_core_LoadBalancerIP_To_v1alpha1_LoadBalancerIP(in *core.LoadBalancerIP, out *v1alpha1.LoadBalancerIP, s conversion.Scope) error { + return autoConvert_core_LoadBalancerIP_To_v1alpha1_LoadBalancerIP(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerList_To_core_LoadBalancerList(in *v1alpha1.LoadBalancerList, out *core.LoadBalancerList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.LoadBalancer)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_LoadBalancerList_To_core_LoadBalancerList is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerList_To_core_LoadBalancerList(in *v1alpha1.LoadBalancerList, out *core.LoadBalancerList, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerList_To_core_LoadBalancerList(in, out, s) +} + +func autoConvert_core_LoadBalancerList_To_v1alpha1_LoadBalancerList(in *core.LoadBalancerList, out *v1alpha1.LoadBalancerList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.LoadBalancer)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_LoadBalancerList_To_v1alpha1_LoadBalancerList is an autogenerated conversion function. +func Convert_core_LoadBalancerList_To_v1alpha1_LoadBalancerList(in *core.LoadBalancerList, out *v1alpha1.LoadBalancerList, s conversion.Scope) error { + return autoConvert_core_LoadBalancerList_To_v1alpha1_LoadBalancerList(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerPort_To_core_LoadBalancerPort(in *v1alpha1.LoadBalancerPort, out *core.LoadBalancerPort, s conversion.Scope) error { + out.Protocol = (*corev1.Protocol)(unsafe.Pointer(in.Protocol)) + out.Port = in.Port + out.EndPort = (*int32)(unsafe.Pointer(in.EndPort)) + return nil +} + +// Convert_v1alpha1_LoadBalancerPort_To_core_LoadBalancerPort is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerPort_To_core_LoadBalancerPort(in *v1alpha1.LoadBalancerPort, out *core.LoadBalancerPort, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerPort_To_core_LoadBalancerPort(in, out, s) +} + +func autoConvert_core_LoadBalancerPort_To_v1alpha1_LoadBalancerPort(in *core.LoadBalancerPort, out *v1alpha1.LoadBalancerPort, s conversion.Scope) error { + out.Protocol = (*corev1.Protocol)(unsafe.Pointer(in.Protocol)) + out.Port = in.Port + out.EndPort = (*int32)(unsafe.Pointer(in.EndPort)) + return nil +} + +// Convert_core_LoadBalancerPort_To_v1alpha1_LoadBalancerPort is an autogenerated conversion function. +func Convert_core_LoadBalancerPort_To_v1alpha1_LoadBalancerPort(in *core.LoadBalancerPort, out *v1alpha1.LoadBalancerPort, s conversion.Scope) error { + return autoConvert_core_LoadBalancerPort_To_v1alpha1_LoadBalancerPort(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerRouting_To_core_LoadBalancerRouting(in *v1alpha1.LoadBalancerRouting, out *core.LoadBalancerRouting, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.Destinations = *(*[]core.LoadBalancerDestination)(unsafe.Pointer(&in.Destinations)) + return nil +} + +// Convert_v1alpha1_LoadBalancerRouting_To_core_LoadBalancerRouting is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerRouting_To_core_LoadBalancerRouting(in *v1alpha1.LoadBalancerRouting, out *core.LoadBalancerRouting, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerRouting_To_core_LoadBalancerRouting(in, out, s) +} + +func autoConvert_core_LoadBalancerRouting_To_v1alpha1_LoadBalancerRouting(in *core.LoadBalancerRouting, out *v1alpha1.LoadBalancerRouting, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.Destinations = *(*[]v1alpha1.LoadBalancerDestination)(unsafe.Pointer(&in.Destinations)) + return nil +} + +// Convert_core_LoadBalancerRouting_To_v1alpha1_LoadBalancerRouting is an autogenerated conversion function. +func Convert_core_LoadBalancerRouting_To_v1alpha1_LoadBalancerRouting(in *core.LoadBalancerRouting, out *v1alpha1.LoadBalancerRouting, s conversion.Scope) error { + return autoConvert_core_LoadBalancerRouting_To_v1alpha1_LoadBalancerRouting(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerRoutingList_To_core_LoadBalancerRoutingList(in *v1alpha1.LoadBalancerRoutingList, out *core.LoadBalancerRoutingList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.LoadBalancerRouting)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_LoadBalancerRoutingList_To_core_LoadBalancerRoutingList is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerRoutingList_To_core_LoadBalancerRoutingList(in *v1alpha1.LoadBalancerRoutingList, out *core.LoadBalancerRoutingList, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerRoutingList_To_core_LoadBalancerRoutingList(in, out, s) +} + +func autoConvert_core_LoadBalancerRoutingList_To_v1alpha1_LoadBalancerRoutingList(in *core.LoadBalancerRoutingList, out *v1alpha1.LoadBalancerRoutingList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.LoadBalancerRouting)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_LoadBalancerRoutingList_To_v1alpha1_LoadBalancerRoutingList is an autogenerated conversion function. +func Convert_core_LoadBalancerRoutingList_To_v1alpha1_LoadBalancerRoutingList(in *core.LoadBalancerRoutingList, out *v1alpha1.LoadBalancerRoutingList, s conversion.Scope) error { + return autoConvert_core_LoadBalancerRoutingList_To_v1alpha1_LoadBalancerRoutingList(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec(in *v1alpha1.LoadBalancerSpec, out *core.LoadBalancerSpec, s conversion.Scope) error { + out.Type = core.LoadBalancerType(in.Type) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]core.LoadBalancerIP)(unsafe.Pointer(&in.IPs)) + out.Ports = *(*[]core.LoadBalancerPort)(unsafe.Pointer(&in.Ports)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + if err := Convert_v1alpha1_InstanceTemplate_To_core_InstanceTemplate(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec(in *v1alpha1.LoadBalancerSpec, out *core.LoadBalancerSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerSpec_To_core_LoadBalancerSpec(in, out, s) +} + +func autoConvert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec(in *core.LoadBalancerSpec, out *v1alpha1.LoadBalancerSpec, s conversion.Scope) error { + out.Type = v1alpha1.LoadBalancerType(in.Type) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]v1alpha1.LoadBalancerIP)(unsafe.Pointer(&in.IPs)) + out.Ports = *(*[]v1alpha1.LoadBalancerPort)(unsafe.Pointer(&in.Ports)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + if err := Convert_core_InstanceTemplate_To_v1alpha1_InstanceTemplate(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec is an autogenerated conversion function. +func Convert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec(in *core.LoadBalancerSpec, out *v1alpha1.LoadBalancerSpec, s conversion.Scope) error { + return autoConvert_core_LoadBalancerSpec_To_v1alpha1_LoadBalancerSpec(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus(in *v1alpha1.LoadBalancerStatus, out *core.LoadBalancerStatus, s conversion.Scope) error { + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + return nil +} + +// Convert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus(in *v1alpha1.LoadBalancerStatus, out *core.LoadBalancerStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerStatus_To_core_LoadBalancerStatus(in, out, s) +} + +func autoConvert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus(in *core.LoadBalancerStatus, out *v1alpha1.LoadBalancerStatus, s conversion.Scope) error { + out.CollisionCount = (*int32)(unsafe.Pointer(in.CollisionCount)) + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + return nil +} + +// Convert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus is an autogenerated conversion function. +func Convert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus(in *core.LoadBalancerStatus, out *v1alpha1.LoadBalancerStatus, s conversion.Scope) error { + return autoConvert_core_LoadBalancerStatus_To_v1alpha1_LoadBalancerStatus(in, out, s) +} + +func autoConvert_v1alpha1_LoadBalancerTargetRef_To_core_LoadBalancerTargetRef(in *v1alpha1.LoadBalancerTargetRef, out *core.LoadBalancerTargetRef, s conversion.Scope) error { + out.UID = types.UID(in.UID) + out.Name = in.Name + out.NodeRef = in.NodeRef + return nil +} + +// Convert_v1alpha1_LoadBalancerTargetRef_To_core_LoadBalancerTargetRef is an autogenerated conversion function. +func Convert_v1alpha1_LoadBalancerTargetRef_To_core_LoadBalancerTargetRef(in *v1alpha1.LoadBalancerTargetRef, out *core.LoadBalancerTargetRef, s conversion.Scope) error { + return autoConvert_v1alpha1_LoadBalancerTargetRef_To_core_LoadBalancerTargetRef(in, out, s) +} + +func autoConvert_core_LoadBalancerTargetRef_To_v1alpha1_LoadBalancerTargetRef(in *core.LoadBalancerTargetRef, out *v1alpha1.LoadBalancerTargetRef, s conversion.Scope) error { + out.UID = types.UID(in.UID) + out.Name = in.Name + out.NodeRef = in.NodeRef + return nil +} + +// Convert_core_LoadBalancerTargetRef_To_v1alpha1_LoadBalancerTargetRef is an autogenerated conversion function. +func Convert_core_LoadBalancerTargetRef_To_v1alpha1_LoadBalancerTargetRef(in *core.LoadBalancerTargetRef, out *v1alpha1.LoadBalancerTargetRef, s conversion.Scope) error { + return autoConvert_core_LoadBalancerTargetRef_To_v1alpha1_LoadBalancerTargetRef(in, out, s) +} + +func autoConvert_v1alpha1_NATGateway_To_core_NATGateway(in *v1alpha1.NATGateway, out *core.NATGateway, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NATGateway_To_core_NATGateway is an autogenerated conversion function. +func Convert_v1alpha1_NATGateway_To_core_NATGateway(in *v1alpha1.NATGateway, out *core.NATGateway, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGateway_To_core_NATGateway(in, out, s) +} + +func autoConvert_core_NATGateway_To_v1alpha1_NATGateway(in *core.NATGateway, out *v1alpha1.NATGateway, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_NATGateway_To_v1alpha1_NATGateway is an autogenerated conversion function. +func Convert_core_NATGateway_To_v1alpha1_NATGateway(in *core.NATGateway, out *v1alpha1.NATGateway, s conversion.Scope) error { + return autoConvert_core_NATGateway_To_v1alpha1_NATGateway(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayAutoscaler_To_core_NATGatewayAutoscaler(in *v1alpha1.NATGatewayAutoscaler, out *core.NATGatewayAutoscaler, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NATGatewayAutoscaler_To_core_NATGatewayAutoscaler is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayAutoscaler_To_core_NATGatewayAutoscaler(in *v1alpha1.NATGatewayAutoscaler, out *core.NATGatewayAutoscaler, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayAutoscaler_To_core_NATGatewayAutoscaler(in, out, s) +} + +func autoConvert_core_NATGatewayAutoscaler_To_v1alpha1_NATGatewayAutoscaler(in *core.NATGatewayAutoscaler, out *v1alpha1.NATGatewayAutoscaler, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_NATGatewayAutoscaler_To_v1alpha1_NATGatewayAutoscaler is an autogenerated conversion function. +func Convert_core_NATGatewayAutoscaler_To_v1alpha1_NATGatewayAutoscaler(in *core.NATGatewayAutoscaler, out *v1alpha1.NATGatewayAutoscaler, s conversion.Scope) error { + return autoConvert_core_NATGatewayAutoscaler_To_v1alpha1_NATGatewayAutoscaler(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayAutoscalerList_To_core_NATGatewayAutoscalerList(in *v1alpha1.NATGatewayAutoscalerList, out *core.NATGatewayAutoscalerList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.NATGatewayAutoscaler)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NATGatewayAutoscalerList_To_core_NATGatewayAutoscalerList is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayAutoscalerList_To_core_NATGatewayAutoscalerList(in *v1alpha1.NATGatewayAutoscalerList, out *core.NATGatewayAutoscalerList, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayAutoscalerList_To_core_NATGatewayAutoscalerList(in, out, s) +} + +func autoConvert_core_NATGatewayAutoscalerList_To_v1alpha1_NATGatewayAutoscalerList(in *core.NATGatewayAutoscalerList, out *v1alpha1.NATGatewayAutoscalerList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.NATGatewayAutoscaler)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NATGatewayAutoscalerList_To_v1alpha1_NATGatewayAutoscalerList is an autogenerated conversion function. +func Convert_core_NATGatewayAutoscalerList_To_v1alpha1_NATGatewayAutoscalerList(in *core.NATGatewayAutoscalerList, out *v1alpha1.NATGatewayAutoscalerList, s conversion.Scope) error { + return autoConvert_core_NATGatewayAutoscalerList_To_v1alpha1_NATGatewayAutoscalerList(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec(in *v1alpha1.NATGatewayAutoscalerSpec, out *core.NATGatewayAutoscalerSpec, s conversion.Scope) error { + out.NATGatewayRef = in.NATGatewayRef + out.MinPublicIPs = (*int32)(unsafe.Pointer(in.MinPublicIPs)) + out.MaxPublicIPs = (*int32)(unsafe.Pointer(in.MaxPublicIPs)) + return nil +} + +// Convert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec(in *v1alpha1.NATGatewayAutoscalerSpec, out *core.NATGatewayAutoscalerSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayAutoscalerSpec_To_core_NATGatewayAutoscalerSpec(in, out, s) +} + +func autoConvert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec(in *core.NATGatewayAutoscalerSpec, out *v1alpha1.NATGatewayAutoscalerSpec, s conversion.Scope) error { + out.NATGatewayRef = in.NATGatewayRef + out.MinPublicIPs = (*int32)(unsafe.Pointer(in.MinPublicIPs)) + out.MaxPublicIPs = (*int32)(unsafe.Pointer(in.MaxPublicIPs)) + return nil +} + +// Convert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec is an autogenerated conversion function. +func Convert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec(in *core.NATGatewayAutoscalerSpec, out *v1alpha1.NATGatewayAutoscalerSpec, s conversion.Scope) error { + return autoConvert_core_NATGatewayAutoscalerSpec_To_v1alpha1_NATGatewayAutoscalerSpec(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus(in *v1alpha1.NATGatewayAutoscalerStatus, out *core.NATGatewayAutoscalerStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus(in *v1alpha1.NATGatewayAutoscalerStatus, out *core.NATGatewayAutoscalerStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayAutoscalerStatus_To_core_NATGatewayAutoscalerStatus(in, out, s) +} + +func autoConvert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus(in *core.NATGatewayAutoscalerStatus, out *v1alpha1.NATGatewayAutoscalerStatus, s conversion.Scope) error { + return nil +} + +// Convert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus is an autogenerated conversion function. +func Convert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus(in *core.NATGatewayAutoscalerStatus, out *v1alpha1.NATGatewayAutoscalerStatus, s conversion.Scope) error { + return autoConvert_core_NATGatewayAutoscalerStatus_To_v1alpha1_NATGatewayAutoscalerStatus(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayIP_To_core_NATGatewayIP(in *v1alpha1.NATGatewayIP, out *core.NATGatewayIP, s conversion.Scope) error { + out.Name = in.Name + out.IP = in.IP + return nil +} + +// Convert_v1alpha1_NATGatewayIP_To_core_NATGatewayIP is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayIP_To_core_NATGatewayIP(in *v1alpha1.NATGatewayIP, out *core.NATGatewayIP, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayIP_To_core_NATGatewayIP(in, out, s) +} + +func autoConvert_core_NATGatewayIP_To_v1alpha1_NATGatewayIP(in *core.NATGatewayIP, out *v1alpha1.NATGatewayIP, s conversion.Scope) error { + out.Name = in.Name + out.IP = in.IP + return nil +} + +// Convert_core_NATGatewayIP_To_v1alpha1_NATGatewayIP is an autogenerated conversion function. +func Convert_core_NATGatewayIP_To_v1alpha1_NATGatewayIP(in *core.NATGatewayIP, out *v1alpha1.NATGatewayIP, s conversion.Scope) error { + return autoConvert_core_NATGatewayIP_To_v1alpha1_NATGatewayIP(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayList_To_core_NATGatewayList(in *v1alpha1.NATGatewayList, out *core.NATGatewayList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.NATGateway)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NATGatewayList_To_core_NATGatewayList is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayList_To_core_NATGatewayList(in *v1alpha1.NATGatewayList, out *core.NATGatewayList, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayList_To_core_NATGatewayList(in, out, s) +} + +func autoConvert_core_NATGatewayList_To_v1alpha1_NATGatewayList(in *core.NATGatewayList, out *v1alpha1.NATGatewayList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.NATGateway)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NATGatewayList_To_v1alpha1_NATGatewayList is an autogenerated conversion function. +func Convert_core_NATGatewayList_To_v1alpha1_NATGatewayList(in *core.NATGatewayList, out *v1alpha1.NATGatewayList, s conversion.Scope) error { + return autoConvert_core_NATGatewayList_To_v1alpha1_NATGatewayList(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec(in *v1alpha1.NATGatewaySpec, out *core.NATGatewaySpec, s conversion.Scope) error { + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]core.NATGatewayIP)(unsafe.Pointer(&in.IPs)) + out.PortsPerNetworkInterface = in.PortsPerNetworkInterface + return nil +} + +// Convert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec(in *v1alpha1.NATGatewaySpec, out *core.NATGatewaySpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewaySpec_To_core_NATGatewaySpec(in, out, s) +} + +func autoConvert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec(in *core.NATGatewaySpec, out *v1alpha1.NATGatewaySpec, s conversion.Scope) error { + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]v1alpha1.NATGatewayIP)(unsafe.Pointer(&in.IPs)) + out.PortsPerNetworkInterface = in.PortsPerNetworkInterface + return nil +} + +// Convert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec is an autogenerated conversion function. +func Convert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec(in *core.NATGatewaySpec, out *v1alpha1.NATGatewaySpec, s conversion.Scope) error { + return autoConvert_core_NATGatewaySpec_To_v1alpha1_NATGatewaySpec(in, out, s) +} + +func autoConvert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus(in *v1alpha1.NATGatewayStatus, out *core.NATGatewayStatus, s conversion.Scope) error { + out.UsedNATIPs = in.UsedNATIPs + out.RequestedNATIPs = in.RequestedNATIPs + return nil +} + +// Convert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus is an autogenerated conversion function. +func Convert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus(in *v1alpha1.NATGatewayStatus, out *core.NATGatewayStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NATGatewayStatus_To_core_NATGatewayStatus(in, out, s) +} + +func autoConvert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus(in *core.NATGatewayStatus, out *v1alpha1.NATGatewayStatus, s conversion.Scope) error { + out.UsedNATIPs = in.UsedNATIPs + out.RequestedNATIPs = in.RequestedNATIPs + return nil +} + +// Convert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus is an autogenerated conversion function. +func Convert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus(in *core.NATGatewayStatus, out *v1alpha1.NATGatewayStatus, s conversion.Scope) error { + return autoConvert_core_NATGatewayStatus_To_v1alpha1_NATGatewayStatus(in, out, s) +} + +func autoConvert_v1alpha1_NATIP_To_core_NATIP(in *v1alpha1.NATIP, out *core.NATIP, s conversion.Scope) error { + out.IP = in.IP + out.Sections = *(*[]core.NATIPSection)(unsafe.Pointer(&in.Sections)) + return nil +} + +// Convert_v1alpha1_NATIP_To_core_NATIP is an autogenerated conversion function. +func Convert_v1alpha1_NATIP_To_core_NATIP(in *v1alpha1.NATIP, out *core.NATIP, s conversion.Scope) error { + return autoConvert_v1alpha1_NATIP_To_core_NATIP(in, out, s) +} + +func autoConvert_core_NATIP_To_v1alpha1_NATIP(in *core.NATIP, out *v1alpha1.NATIP, s conversion.Scope) error { + out.IP = in.IP + out.Sections = *(*[]v1alpha1.NATIPSection)(unsafe.Pointer(&in.Sections)) + return nil +} + +// Convert_core_NATIP_To_v1alpha1_NATIP is an autogenerated conversion function. +func Convert_core_NATIP_To_v1alpha1_NATIP(in *core.NATIP, out *v1alpha1.NATIP, s conversion.Scope) error { + return autoConvert_core_NATIP_To_v1alpha1_NATIP(in, out, s) +} + +func autoConvert_v1alpha1_NATIPSection_To_core_NATIPSection(in *v1alpha1.NATIPSection, out *core.NATIPSection, s conversion.Scope) error { + out.IP = in.IP + out.Port = in.Port + out.EndPort = in.EndPort + out.TargetRef = (*core.NATTableIPTargetRef)(unsafe.Pointer(in.TargetRef)) + return nil +} + +// Convert_v1alpha1_NATIPSection_To_core_NATIPSection is an autogenerated conversion function. +func Convert_v1alpha1_NATIPSection_To_core_NATIPSection(in *v1alpha1.NATIPSection, out *core.NATIPSection, s conversion.Scope) error { + return autoConvert_v1alpha1_NATIPSection_To_core_NATIPSection(in, out, s) +} + +func autoConvert_core_NATIPSection_To_v1alpha1_NATIPSection(in *core.NATIPSection, out *v1alpha1.NATIPSection, s conversion.Scope) error { + out.IP = in.IP + out.Port = in.Port + out.EndPort = in.EndPort + out.TargetRef = (*v1alpha1.NATTableIPTargetRef)(unsafe.Pointer(in.TargetRef)) + return nil +} + +// Convert_core_NATIPSection_To_v1alpha1_NATIPSection is an autogenerated conversion function. +func Convert_core_NATIPSection_To_v1alpha1_NATIPSection(in *core.NATIPSection, out *v1alpha1.NATIPSection, s conversion.Scope) error { + return autoConvert_core_NATIPSection_To_v1alpha1_NATIPSection(in, out, s) +} + +func autoConvert_v1alpha1_NATTable_To_core_NATTable(in *v1alpha1.NATTable, out *core.NATTable, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.IPs = *(*[]core.NATIP)(unsafe.Pointer(&in.IPs)) + return nil +} + +// Convert_v1alpha1_NATTable_To_core_NATTable is an autogenerated conversion function. +func Convert_v1alpha1_NATTable_To_core_NATTable(in *v1alpha1.NATTable, out *core.NATTable, s conversion.Scope) error { + return autoConvert_v1alpha1_NATTable_To_core_NATTable(in, out, s) +} + +func autoConvert_core_NATTable_To_v1alpha1_NATTable(in *core.NATTable, out *v1alpha1.NATTable, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + out.IPs = *(*[]v1alpha1.NATIP)(unsafe.Pointer(&in.IPs)) + return nil +} + +// Convert_core_NATTable_To_v1alpha1_NATTable is an autogenerated conversion function. +func Convert_core_NATTable_To_v1alpha1_NATTable(in *core.NATTable, out *v1alpha1.NATTable, s conversion.Scope) error { + return autoConvert_core_NATTable_To_v1alpha1_NATTable(in, out, s) +} + +func autoConvert_v1alpha1_NATTableIPTargetRef_To_core_NATTableIPTargetRef(in *v1alpha1.NATTableIPTargetRef, out *core.NATTableIPTargetRef, s conversion.Scope) error { + out.UID = types.UID(in.UID) + out.Name = in.Name + out.NodeRef = in.NodeRef + return nil +} + +// Convert_v1alpha1_NATTableIPTargetRef_To_core_NATTableIPTargetRef is an autogenerated conversion function. +func Convert_v1alpha1_NATTableIPTargetRef_To_core_NATTableIPTargetRef(in *v1alpha1.NATTableIPTargetRef, out *core.NATTableIPTargetRef, s conversion.Scope) error { + return autoConvert_v1alpha1_NATTableIPTargetRef_To_core_NATTableIPTargetRef(in, out, s) +} + +func autoConvert_core_NATTableIPTargetRef_To_v1alpha1_NATTableIPTargetRef(in *core.NATTableIPTargetRef, out *v1alpha1.NATTableIPTargetRef, s conversion.Scope) error { + out.UID = types.UID(in.UID) + out.Name = in.Name + out.NodeRef = in.NodeRef + return nil +} + +// Convert_core_NATTableIPTargetRef_To_v1alpha1_NATTableIPTargetRef is an autogenerated conversion function. +func Convert_core_NATTableIPTargetRef_To_v1alpha1_NATTableIPTargetRef(in *core.NATTableIPTargetRef, out *v1alpha1.NATTableIPTargetRef, s conversion.Scope) error { + return autoConvert_core_NATTableIPTargetRef_To_v1alpha1_NATTableIPTargetRef(in, out, s) +} + +func autoConvert_v1alpha1_NATTableList_To_core_NATTableList(in *v1alpha1.NATTableList, out *core.NATTableList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.NATTable)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NATTableList_To_core_NATTableList is an autogenerated conversion function. +func Convert_v1alpha1_NATTableList_To_core_NATTableList(in *v1alpha1.NATTableList, out *core.NATTableList, s conversion.Scope) error { + return autoConvert_v1alpha1_NATTableList_To_core_NATTableList(in, out, s) +} + +func autoConvert_core_NATTableList_To_v1alpha1_NATTableList(in *core.NATTableList, out *v1alpha1.NATTableList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.NATTable)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NATTableList_To_v1alpha1_NATTableList is an autogenerated conversion function. +func Convert_core_NATTableList_To_v1alpha1_NATTableList(in *core.NATTableList, out *v1alpha1.NATTableList, s conversion.Scope) error { + return autoConvert_core_NATTableList_To_v1alpha1_NATTableList(in, out, s) +} + +func autoConvert_v1alpha1_Network_To_core_Network(in *v1alpha1.Network, out *core.Network, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NetworkSpec_To_core_NetworkSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_NetworkStatus_To_core_NetworkStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_Network_To_core_Network is an autogenerated conversion function. +func Convert_v1alpha1_Network_To_core_Network(in *v1alpha1.Network, out *core.Network, s conversion.Scope) error { + return autoConvert_v1alpha1_Network_To_core_Network(in, out, s) +} + +func autoConvert_core_Network_To_v1alpha1_Network(in *core.Network, out *v1alpha1.Network, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NetworkSpec_To_v1alpha1_NetworkSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_NetworkStatus_To_v1alpha1_NetworkStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_Network_To_v1alpha1_Network is an autogenerated conversion function. +func Convert_core_Network_To_v1alpha1_Network(in *core.Network, out *v1alpha1.Network, s conversion.Scope) error { + return autoConvert_core_Network_To_v1alpha1_Network(in, out, s) +} + +func autoConvert_v1alpha1_NetworkID_To_core_NetworkID(in *v1alpha1.NetworkID, out *core.NetworkID, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NetworkID_To_core_NetworkID is an autogenerated conversion function. +func Convert_v1alpha1_NetworkID_To_core_NetworkID(in *v1alpha1.NetworkID, out *core.NetworkID, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkID_To_core_NetworkID(in, out, s) +} + +func autoConvert_core_NetworkID_To_v1alpha1_NetworkID(in *core.NetworkID, out *v1alpha1.NetworkID, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_core_NetworkID_To_v1alpha1_NetworkID is an autogenerated conversion function. +func Convert_core_NetworkID_To_v1alpha1_NetworkID(in *core.NetworkID, out *v1alpha1.NetworkID, s conversion.Scope) error { + return autoConvert_core_NetworkID_To_v1alpha1_NetworkID(in, out, s) +} + +func autoConvert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef(in *v1alpha1.NetworkIDClaimRef, out *core.NetworkIDClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Namespace = in.Namespace + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef is an autogenerated conversion function. +func Convert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef(in *v1alpha1.NetworkIDClaimRef, out *core.NetworkIDClaimRef, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef(in, out, s) +} + +func autoConvert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef(in *core.NetworkIDClaimRef, out *v1alpha1.NetworkIDClaimRef, s conversion.Scope) error { + out.Group = in.Group + out.Resource = in.Resource + out.Namespace = in.Namespace + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef is an autogenerated conversion function. +func Convert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef(in *core.NetworkIDClaimRef, out *v1alpha1.NetworkIDClaimRef, s conversion.Scope) error { + return autoConvert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef(in, out, s) +} + +func autoConvert_v1alpha1_NetworkIDList_To_core_NetworkIDList(in *v1alpha1.NetworkIDList, out *core.NetworkIDList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.NetworkID)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NetworkIDList_To_core_NetworkIDList is an autogenerated conversion function. +func Convert_v1alpha1_NetworkIDList_To_core_NetworkIDList(in *v1alpha1.NetworkIDList, out *core.NetworkIDList, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkIDList_To_core_NetworkIDList(in, out, s) +} + +func autoConvert_core_NetworkIDList_To_v1alpha1_NetworkIDList(in *core.NetworkIDList, out *v1alpha1.NetworkIDList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.NetworkID)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NetworkIDList_To_v1alpha1_NetworkIDList is an autogenerated conversion function. +func Convert_core_NetworkIDList_To_v1alpha1_NetworkIDList(in *core.NetworkIDList, out *v1alpha1.NetworkIDList, s conversion.Scope) error { + return autoConvert_core_NetworkIDList_To_v1alpha1_NetworkIDList(in, out, s) +} + +func autoConvert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec(in *v1alpha1.NetworkIDSpec, out *core.NetworkIDSpec, s conversion.Scope) error { + if err := Convert_v1alpha1_NetworkIDClaimRef_To_core_NetworkIDClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec is an autogenerated conversion function. +func Convert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec(in *v1alpha1.NetworkIDSpec, out *core.NetworkIDSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkIDSpec_To_core_NetworkIDSpec(in, out, s) +} + +func autoConvert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec(in *core.NetworkIDSpec, out *v1alpha1.NetworkIDSpec, s conversion.Scope) error { + if err := Convert_core_NetworkIDClaimRef_To_v1alpha1_NetworkIDClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec is an autogenerated conversion function. +func Convert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec(in *core.NetworkIDSpec, out *v1alpha1.NetworkIDSpec, s conversion.Scope) error { + return autoConvert_core_NetworkIDSpec_To_v1alpha1_NetworkIDSpec(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterface_To_core_NetworkInterface(in *v1alpha1.NetworkInterface, out *core.NetworkInterface, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NetworkInterface_To_core_NetworkInterface is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterface_To_core_NetworkInterface(in *v1alpha1.NetworkInterface, out *core.NetworkInterface, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterface_To_core_NetworkInterface(in, out, s) +} + +func autoConvert_core_NetworkInterface_To_v1alpha1_NetworkInterface(in *core.NetworkInterface, out *v1alpha1.NetworkInterface, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_NetworkInterface_To_v1alpha1_NetworkInterface is an autogenerated conversion function. +func Convert_core_NetworkInterface_To_v1alpha1_NetworkInterface(in *core.NetworkInterface, out *v1alpha1.NetworkInterface, s conversion.Scope) error { + return autoConvert_core_NetworkInterface_To_v1alpha1_NetworkInterface(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfaceList_To_core_NetworkInterfaceList(in *v1alpha1.NetworkInterfaceList, out *core.NetworkInterfaceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.NetworkInterface)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NetworkInterfaceList_To_core_NetworkInterfaceList is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfaceList_To_core_NetworkInterfaceList(in *v1alpha1.NetworkInterfaceList, out *core.NetworkInterfaceList, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfaceList_To_core_NetworkInterfaceList(in, out, s) +} + +func autoConvert_core_NetworkInterfaceList_To_v1alpha1_NetworkInterfaceList(in *core.NetworkInterfaceList, out *v1alpha1.NetworkInterfaceList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.NetworkInterface)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NetworkInterfaceList_To_v1alpha1_NetworkInterfaceList is an autogenerated conversion function. +func Convert_core_NetworkInterfaceList_To_v1alpha1_NetworkInterfaceList(in *core.NetworkInterfaceList, out *v1alpha1.NetworkInterfaceList, s conversion.Scope) error { + return autoConvert_core_NetworkInterfaceList_To_v1alpha1_NetworkInterfaceList(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfaceNAT_To_core_NetworkInterfaceNAT(in *v1alpha1.NetworkInterfaceNAT, out *core.NetworkInterfaceNAT, s conversion.Scope) error { + out.IPFamily = corev1.IPFamily(in.IPFamily) + if err := Convert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_NetworkInterfaceNAT_To_core_NetworkInterfaceNAT is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfaceNAT_To_core_NetworkInterfaceNAT(in *v1alpha1.NetworkInterfaceNAT, out *core.NetworkInterfaceNAT, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfaceNAT_To_core_NetworkInterfaceNAT(in, out, s) +} + +func autoConvert_core_NetworkInterfaceNAT_To_v1alpha1_NetworkInterfaceNAT(in *core.NetworkInterfaceNAT, out *v1alpha1.NetworkInterfaceNAT, s conversion.Scope) error { + out.IPFamily = corev1.IPFamily(in.IPFamily) + if err := Convert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef(&in.ClaimRef, &out.ClaimRef, s); err != nil { + return err + } + return nil +} + +// Convert_core_NetworkInterfaceNAT_To_v1alpha1_NetworkInterfaceNAT is an autogenerated conversion function. +func Convert_core_NetworkInterfaceNAT_To_v1alpha1_NetworkInterfaceNAT(in *core.NetworkInterfaceNAT, out *v1alpha1.NetworkInterfaceNAT, s conversion.Scope) error { + return autoConvert_core_NetworkInterfaceNAT_To_v1alpha1_NetworkInterfaceNAT(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef(in *v1alpha1.NetworkInterfaceNATClaimRef, out *core.NetworkInterfaceNATClaimRef, s conversion.Scope) error { + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef(in *v1alpha1.NetworkInterfaceNATClaimRef, out *core.NetworkInterfaceNATClaimRef, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfaceNATClaimRef_To_core_NetworkInterfaceNATClaimRef(in, out, s) +} + +func autoConvert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef(in *core.NetworkInterfaceNATClaimRef, out *v1alpha1.NetworkInterfaceNATClaimRef, s conversion.Scope) error { + out.Name = in.Name + out.UID = types.UID(in.UID) + return nil +} + +// Convert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef is an autogenerated conversion function. +func Convert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef(in *core.NetworkInterfaceNATClaimRef, out *v1alpha1.NetworkInterfaceNATClaimRef, s conversion.Scope) error { + return autoConvert_core_NetworkInterfaceNATClaimRef_To_v1alpha1_NetworkInterfaceNATClaimRef(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfacePublicIP_To_core_NetworkInterfacePublicIP(in *v1alpha1.NetworkInterfacePublicIP, out *core.NetworkInterfacePublicIP, s conversion.Scope) error { + out.Name = in.Name + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + return nil +} + +// Convert_v1alpha1_NetworkInterfacePublicIP_To_core_NetworkInterfacePublicIP is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfacePublicIP_To_core_NetworkInterfacePublicIP(in *v1alpha1.NetworkInterfacePublicIP, out *core.NetworkInterfacePublicIP, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfacePublicIP_To_core_NetworkInterfacePublicIP(in, out, s) +} + +func autoConvert_core_NetworkInterfacePublicIP_To_v1alpha1_NetworkInterfacePublicIP(in *core.NetworkInterfacePublicIP, out *v1alpha1.NetworkInterfacePublicIP, s conversion.Scope) error { + out.Name = in.Name + out.IPFamily = corev1.IPFamily(in.IPFamily) + out.IP = in.IP + return nil +} + +// Convert_core_NetworkInterfacePublicIP_To_v1alpha1_NetworkInterfacePublicIP is an autogenerated conversion function. +func Convert_core_NetworkInterfacePublicIP_To_v1alpha1_NetworkInterfacePublicIP(in *core.NetworkInterfacePublicIP, out *v1alpha1.NetworkInterfacePublicIP, s conversion.Scope) error { + return autoConvert_core_NetworkInterfacePublicIP_To_v1alpha1_NetworkInterfacePublicIP(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec(in *v1alpha1.NetworkInterfaceSpec, out *core.NetworkInterfaceSpec, s conversion.Scope) error { + out.NodeRef = in.NodeRef + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.Prefixes = *(*[]net.IPPrefix)(unsafe.Pointer(&in.Prefixes)) + out.NATs = *(*[]core.NetworkInterfaceNAT)(unsafe.Pointer(&in.NATs)) + out.PublicIPs = *(*[]core.NetworkInterfacePublicIP)(unsafe.Pointer(&in.PublicIPs)) + return nil +} + +// Convert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec(in *v1alpha1.NetworkInterfaceSpec, out *core.NetworkInterfaceSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfaceSpec_To_core_NetworkInterfaceSpec(in, out, s) +} + +func autoConvert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec(in *core.NetworkInterfaceSpec, out *v1alpha1.NetworkInterfaceSpec, s conversion.Scope) error { + out.NodeRef = in.NodeRef + out.NetworkRef = in.NetworkRef + out.IPs = *(*[]net.IP)(unsafe.Pointer(&in.IPs)) + out.Prefixes = *(*[]net.IPPrefix)(unsafe.Pointer(&in.Prefixes)) + out.NATs = *(*[]v1alpha1.NetworkInterfaceNAT)(unsafe.Pointer(&in.NATs)) + out.PublicIPs = *(*[]v1alpha1.NetworkInterfacePublicIP)(unsafe.Pointer(&in.PublicIPs)) + return nil +} + +// Convert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec is an autogenerated conversion function. +func Convert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec(in *core.NetworkInterfaceSpec, out *v1alpha1.NetworkInterfaceSpec, s conversion.Scope) error { + return autoConvert_core_NetworkInterfaceSpec_To_v1alpha1_NetworkInterfaceSpec(in, out, s) +} + +func autoConvert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus(in *v1alpha1.NetworkInterfaceStatus, out *core.NetworkInterfaceStatus, s conversion.Scope) error { + out.State = core.NetworkInterfaceState(in.State) + out.PCIAddress = (*core.PCIAddress)(unsafe.Pointer(in.PCIAddress)) + out.Prefixes = *(*[]net.IPPrefix)(unsafe.Pointer(&in.Prefixes)) + out.PublicIPs = *(*[]net.IP)(unsafe.Pointer(&in.PublicIPs)) + out.NATIPs = *(*[]net.IP)(unsafe.Pointer(&in.NATIPs)) + return nil +} + +// Convert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus is an autogenerated conversion function. +func Convert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus(in *v1alpha1.NetworkInterfaceStatus, out *core.NetworkInterfaceStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkInterfaceStatus_To_core_NetworkInterfaceStatus(in, out, s) +} + +func autoConvert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus(in *core.NetworkInterfaceStatus, out *v1alpha1.NetworkInterfaceStatus, s conversion.Scope) error { + out.State = v1alpha1.NetworkInterfaceState(in.State) + out.PCIAddress = (*v1alpha1.PCIAddress)(unsafe.Pointer(in.PCIAddress)) + out.Prefixes = *(*[]net.IPPrefix)(unsafe.Pointer(&in.Prefixes)) + out.PublicIPs = *(*[]net.IP)(unsafe.Pointer(&in.PublicIPs)) + out.NATIPs = *(*[]net.IP)(unsafe.Pointer(&in.NATIPs)) + return nil +} + +// Convert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus is an autogenerated conversion function. +func Convert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus(in *core.NetworkInterfaceStatus, out *v1alpha1.NetworkInterfaceStatus, s conversion.Scope) error { + return autoConvert_core_NetworkInterfaceStatus_To_v1alpha1_NetworkInterfaceStatus(in, out, s) +} + +func autoConvert_v1alpha1_NetworkList_To_core_NetworkList(in *v1alpha1.NetworkList, out *core.NetworkList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.Network)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NetworkList_To_core_NetworkList is an autogenerated conversion function. +func Convert_v1alpha1_NetworkList_To_core_NetworkList(in *v1alpha1.NetworkList, out *core.NetworkList, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkList_To_core_NetworkList(in, out, s) +} + +func autoConvert_core_NetworkList_To_v1alpha1_NetworkList(in *core.NetworkList, out *v1alpha1.NetworkList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.Network)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NetworkList_To_v1alpha1_NetworkList is an autogenerated conversion function. +func Convert_core_NetworkList_To_v1alpha1_NetworkList(in *core.NetworkList, out *v1alpha1.NetworkList, s conversion.Scope) error { + return autoConvert_core_NetworkList_To_v1alpha1_NetworkList(in, out, s) +} + +func autoConvert_v1alpha1_NetworkSpec_To_core_NetworkSpec(in *v1alpha1.NetworkSpec, out *core.NetworkSpec, s conversion.Scope) error { + out.ID = in.ID + return nil +} + +// Convert_v1alpha1_NetworkSpec_To_core_NetworkSpec is an autogenerated conversion function. +func Convert_v1alpha1_NetworkSpec_To_core_NetworkSpec(in *v1alpha1.NetworkSpec, out *core.NetworkSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkSpec_To_core_NetworkSpec(in, out, s) +} + +func autoConvert_core_NetworkSpec_To_v1alpha1_NetworkSpec(in *core.NetworkSpec, out *v1alpha1.NetworkSpec, s conversion.Scope) error { + out.ID = in.ID + return nil +} + +// Convert_core_NetworkSpec_To_v1alpha1_NetworkSpec is an autogenerated conversion function. +func Convert_core_NetworkSpec_To_v1alpha1_NetworkSpec(in *core.NetworkSpec, out *v1alpha1.NetworkSpec, s conversion.Scope) error { + return autoConvert_core_NetworkSpec_To_v1alpha1_NetworkSpec(in, out, s) +} + +func autoConvert_v1alpha1_NetworkStatus_To_core_NetworkStatus(in *v1alpha1.NetworkStatus, out *core.NetworkStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_NetworkStatus_To_core_NetworkStatus is an autogenerated conversion function. +func Convert_v1alpha1_NetworkStatus_To_core_NetworkStatus(in *v1alpha1.NetworkStatus, out *core.NetworkStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NetworkStatus_To_core_NetworkStatus(in, out, s) +} + +func autoConvert_core_NetworkStatus_To_v1alpha1_NetworkStatus(in *core.NetworkStatus, out *v1alpha1.NetworkStatus, s conversion.Scope) error { + return nil +} + +// Convert_core_NetworkStatus_To_v1alpha1_NetworkStatus is an autogenerated conversion function. +func Convert_core_NetworkStatus_To_v1alpha1_NetworkStatus(in *core.NetworkStatus, out *v1alpha1.NetworkStatus, s conversion.Scope) error { + return autoConvert_core_NetworkStatus_To_v1alpha1_NetworkStatus(in, out, s) +} + +func autoConvert_v1alpha1_Node_To_core_Node(in *v1alpha1.Node, out *core.Node, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_NodeSpec_To_core_NodeSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_NodeStatus_To_core_NodeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_Node_To_core_Node is an autogenerated conversion function. +func Convert_v1alpha1_Node_To_core_Node(in *v1alpha1.Node, out *core.Node, s conversion.Scope) error { + return autoConvert_v1alpha1_Node_To_core_Node(in, out, s) +} + +func autoConvert_core_Node_To_v1alpha1_Node(in *core.Node, out *v1alpha1.Node, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_core_NodeSpec_To_v1alpha1_NodeSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_core_NodeStatus_To_v1alpha1_NodeStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_core_Node_To_v1alpha1_Node is an autogenerated conversion function. +func Convert_core_Node_To_v1alpha1_Node(in *core.Node, out *v1alpha1.Node, s conversion.Scope) error { + return autoConvert_core_Node_To_v1alpha1_Node(in, out, s) +} + +func autoConvert_v1alpha1_NodeAffinity_To_core_NodeAffinity(in *v1alpha1.NodeAffinity, out *core.NodeAffinity, s conversion.Scope) error { + out.RequiredDuringSchedulingIgnoredDuringExecution = (*core.NodeSelector)(unsafe.Pointer(in.RequiredDuringSchedulingIgnoredDuringExecution)) + return nil +} + +// Convert_v1alpha1_NodeAffinity_To_core_NodeAffinity is an autogenerated conversion function. +func Convert_v1alpha1_NodeAffinity_To_core_NodeAffinity(in *v1alpha1.NodeAffinity, out *core.NodeAffinity, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeAffinity_To_core_NodeAffinity(in, out, s) +} + +func autoConvert_core_NodeAffinity_To_v1alpha1_NodeAffinity(in *core.NodeAffinity, out *v1alpha1.NodeAffinity, s conversion.Scope) error { + out.RequiredDuringSchedulingIgnoredDuringExecution = (*v1alpha1.NodeSelector)(unsafe.Pointer(in.RequiredDuringSchedulingIgnoredDuringExecution)) + return nil +} + +// Convert_core_NodeAffinity_To_v1alpha1_NodeAffinity is an autogenerated conversion function. +func Convert_core_NodeAffinity_To_v1alpha1_NodeAffinity(in *core.NodeAffinity, out *v1alpha1.NodeAffinity, s conversion.Scope) error { + return autoConvert_core_NodeAffinity_To_v1alpha1_NodeAffinity(in, out, s) +} + +func autoConvert_v1alpha1_NodeList_To_core_NodeList(in *v1alpha1.NodeList, out *core.NodeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]core.Node)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_NodeList_To_core_NodeList is an autogenerated conversion function. +func Convert_v1alpha1_NodeList_To_core_NodeList(in *v1alpha1.NodeList, out *core.NodeList, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeList_To_core_NodeList(in, out, s) +} + +func autoConvert_core_NodeList_To_v1alpha1_NodeList(in *core.NodeList, out *v1alpha1.NodeList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]v1alpha1.Node)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_core_NodeList_To_v1alpha1_NodeList is an autogenerated conversion function. +func Convert_core_NodeList_To_v1alpha1_NodeList(in *core.NodeList, out *v1alpha1.NodeList, s conversion.Scope) error { + return autoConvert_core_NodeList_To_v1alpha1_NodeList(in, out, s) +} + +func autoConvert_v1alpha1_NodeSelector_To_core_NodeSelector(in *v1alpha1.NodeSelector, out *core.NodeSelector, s conversion.Scope) error { + out.NodeSelectorTerms = *(*[]core.NodeSelectorTerm)(unsafe.Pointer(&in.NodeSelectorTerms)) + return nil +} + +// Convert_v1alpha1_NodeSelector_To_core_NodeSelector is an autogenerated conversion function. +func Convert_v1alpha1_NodeSelector_To_core_NodeSelector(in *v1alpha1.NodeSelector, out *core.NodeSelector, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeSelector_To_core_NodeSelector(in, out, s) +} + +func autoConvert_core_NodeSelector_To_v1alpha1_NodeSelector(in *core.NodeSelector, out *v1alpha1.NodeSelector, s conversion.Scope) error { + out.NodeSelectorTerms = *(*[]v1alpha1.NodeSelectorTerm)(unsafe.Pointer(&in.NodeSelectorTerms)) + return nil +} + +// Convert_core_NodeSelector_To_v1alpha1_NodeSelector is an autogenerated conversion function. +func Convert_core_NodeSelector_To_v1alpha1_NodeSelector(in *core.NodeSelector, out *v1alpha1.NodeSelector, s conversion.Scope) error { + return autoConvert_core_NodeSelector_To_v1alpha1_NodeSelector(in, out, s) +} + +func autoConvert_v1alpha1_NodeSelectorRequirement_To_core_NodeSelectorRequirement(in *v1alpha1.NodeSelectorRequirement, out *core.NodeSelectorRequirement, s conversion.Scope) error { + out.Key = in.Key + out.Operator = core.NodeSelectorOperator(in.Operator) + out.Values = *(*[]string)(unsafe.Pointer(&in.Values)) + return nil +} + +// Convert_v1alpha1_NodeSelectorRequirement_To_core_NodeSelectorRequirement is an autogenerated conversion function. +func Convert_v1alpha1_NodeSelectorRequirement_To_core_NodeSelectorRequirement(in *v1alpha1.NodeSelectorRequirement, out *core.NodeSelectorRequirement, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeSelectorRequirement_To_core_NodeSelectorRequirement(in, out, s) +} + +func autoConvert_core_NodeSelectorRequirement_To_v1alpha1_NodeSelectorRequirement(in *core.NodeSelectorRequirement, out *v1alpha1.NodeSelectorRequirement, s conversion.Scope) error { + out.Key = in.Key + out.Operator = v1alpha1.NodeSelectorOperator(in.Operator) + out.Values = *(*[]string)(unsafe.Pointer(&in.Values)) + return nil +} + +// Convert_core_NodeSelectorRequirement_To_v1alpha1_NodeSelectorRequirement is an autogenerated conversion function. +func Convert_core_NodeSelectorRequirement_To_v1alpha1_NodeSelectorRequirement(in *core.NodeSelectorRequirement, out *v1alpha1.NodeSelectorRequirement, s conversion.Scope) error { + return autoConvert_core_NodeSelectorRequirement_To_v1alpha1_NodeSelectorRequirement(in, out, s) +} + +func autoConvert_v1alpha1_NodeSelectorTerm_To_core_NodeSelectorTerm(in *v1alpha1.NodeSelectorTerm, out *core.NodeSelectorTerm, s conversion.Scope) error { + out.MatchExpressions = *(*[]core.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions)) + out.MatchFields = *(*[]core.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchFields)) + return nil +} + +// Convert_v1alpha1_NodeSelectorTerm_To_core_NodeSelectorTerm is an autogenerated conversion function. +func Convert_v1alpha1_NodeSelectorTerm_To_core_NodeSelectorTerm(in *v1alpha1.NodeSelectorTerm, out *core.NodeSelectorTerm, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeSelectorTerm_To_core_NodeSelectorTerm(in, out, s) +} + +func autoConvert_core_NodeSelectorTerm_To_v1alpha1_NodeSelectorTerm(in *core.NodeSelectorTerm, out *v1alpha1.NodeSelectorTerm, s conversion.Scope) error { + out.MatchExpressions = *(*[]v1alpha1.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions)) + out.MatchFields = *(*[]v1alpha1.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchFields)) + return nil +} + +// Convert_core_NodeSelectorTerm_To_v1alpha1_NodeSelectorTerm is an autogenerated conversion function. +func Convert_core_NodeSelectorTerm_To_v1alpha1_NodeSelectorTerm(in *core.NodeSelectorTerm, out *v1alpha1.NodeSelectorTerm, s conversion.Scope) error { + return autoConvert_core_NodeSelectorTerm_To_v1alpha1_NodeSelectorTerm(in, out, s) +} + +func autoConvert_v1alpha1_NodeSpec_To_core_NodeSpec(in *v1alpha1.NodeSpec, out *core.NodeSpec, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_NodeSpec_To_core_NodeSpec is an autogenerated conversion function. +func Convert_v1alpha1_NodeSpec_To_core_NodeSpec(in *v1alpha1.NodeSpec, out *core.NodeSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeSpec_To_core_NodeSpec(in, out, s) +} + +func autoConvert_core_NodeSpec_To_v1alpha1_NodeSpec(in *core.NodeSpec, out *v1alpha1.NodeSpec, s conversion.Scope) error { + return nil +} + +// Convert_core_NodeSpec_To_v1alpha1_NodeSpec is an autogenerated conversion function. +func Convert_core_NodeSpec_To_v1alpha1_NodeSpec(in *core.NodeSpec, out *v1alpha1.NodeSpec, s conversion.Scope) error { + return autoConvert_core_NodeSpec_To_v1alpha1_NodeSpec(in, out, s) +} + +func autoConvert_v1alpha1_NodeStatus_To_core_NodeStatus(in *v1alpha1.NodeStatus, out *core.NodeStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_NodeStatus_To_core_NodeStatus is an autogenerated conversion function. +func Convert_v1alpha1_NodeStatus_To_core_NodeStatus(in *v1alpha1.NodeStatus, out *core.NodeStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_NodeStatus_To_core_NodeStatus(in, out, s) +} + +func autoConvert_core_NodeStatus_To_v1alpha1_NodeStatus(in *core.NodeStatus, out *v1alpha1.NodeStatus, s conversion.Scope) error { + return nil +} + +// Convert_core_NodeStatus_To_v1alpha1_NodeStatus is an autogenerated conversion function. +func Convert_core_NodeStatus_To_v1alpha1_NodeStatus(in *core.NodeStatus, out *v1alpha1.NodeStatus, s conversion.Scope) error { + return autoConvert_core_NodeStatus_To_v1alpha1_NodeStatus(in, out, s) +} + +func autoConvert_v1alpha1_PCIAddress_To_core_PCIAddress(in *v1alpha1.PCIAddress, out *core.PCIAddress, s conversion.Scope) error { + out.Domain = in.Domain + out.Bus = in.Bus + out.Slot = in.Slot + out.Function = in.Function + return nil +} + +// Convert_v1alpha1_PCIAddress_To_core_PCIAddress is an autogenerated conversion function. +func Convert_v1alpha1_PCIAddress_To_core_PCIAddress(in *v1alpha1.PCIAddress, out *core.PCIAddress, s conversion.Scope) error { + return autoConvert_v1alpha1_PCIAddress_To_core_PCIAddress(in, out, s) +} + +func autoConvert_core_PCIAddress_To_v1alpha1_PCIAddress(in *core.PCIAddress, out *v1alpha1.PCIAddress, s conversion.Scope) error { + out.Domain = in.Domain + out.Bus = in.Bus + out.Slot = in.Slot + out.Function = in.Function + return nil +} + +// Convert_core_PCIAddress_To_v1alpha1_PCIAddress is an autogenerated conversion function. +func Convert_core_PCIAddress_To_v1alpha1_PCIAddress(in *core.PCIAddress, out *v1alpha1.PCIAddress, s conversion.Scope) error { + return autoConvert_core_PCIAddress_To_v1alpha1_PCIAddress(in, out, s) +} + +func autoConvert_v1alpha1_TopologySpreadConstraint_To_core_TopologySpreadConstraint(in *v1alpha1.TopologySpreadConstraint, out *core.TopologySpreadConstraint, s conversion.Scope) error { + out.MaxSkew = in.MaxSkew + out.TopologyKey = in.TopologyKey + out.WhenUnsatisfiable = core.UnsatisfiableConstraintAction(in.WhenUnsatisfiable) + out.LabelSelector = (*v1.LabelSelector)(unsafe.Pointer(in.LabelSelector)) + return nil +} + +// Convert_v1alpha1_TopologySpreadConstraint_To_core_TopologySpreadConstraint is an autogenerated conversion function. +func Convert_v1alpha1_TopologySpreadConstraint_To_core_TopologySpreadConstraint(in *v1alpha1.TopologySpreadConstraint, out *core.TopologySpreadConstraint, s conversion.Scope) error { + return autoConvert_v1alpha1_TopologySpreadConstraint_To_core_TopologySpreadConstraint(in, out, s) +} + +func autoConvert_core_TopologySpreadConstraint_To_v1alpha1_TopologySpreadConstraint(in *core.TopologySpreadConstraint, out *v1alpha1.TopologySpreadConstraint, s conversion.Scope) error { + out.MaxSkew = in.MaxSkew + out.TopologyKey = in.TopologyKey + out.WhenUnsatisfiable = v1alpha1.UnsatisfiableConstraintAction(in.WhenUnsatisfiable) + out.LabelSelector = (*v1.LabelSelector)(unsafe.Pointer(in.LabelSelector)) + return nil +} + +// Convert_core_TopologySpreadConstraint_To_v1alpha1_TopologySpreadConstraint is an autogenerated conversion function. +func Convert_core_TopologySpreadConstraint_To_v1alpha1_TopologySpreadConstraint(in *core.TopologySpreadConstraint, out *v1alpha1.TopologySpreadConstraint, s conversion.Scope) error { + return autoConvert_core_TopologySpreadConstraint_To_v1alpha1_TopologySpreadConstraint(in, out, s) +} diff --git a/internal/apis/core/v1alpha1/zz_generated.defaults.go b/internal/apis/core/v1alpha1/zz_generated.defaults.go new file mode 100644 index 00000000..fa33f7b0 --- /dev/null +++ b/internal/apis/core/v1alpha1/zz_generated.defaults.go @@ -0,0 +1,46 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * Copyright (c) 2022 by the OnMetal 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 defaulter-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + scheme.AddTypeDefaultingFunc(&v1alpha1.IP{}, func(obj interface{}) { SetObjectDefaults_IP(obj.(*v1alpha1.IP)) }) + scheme.AddTypeDefaultingFunc(&v1alpha1.IPList{}, func(obj interface{}) { SetObjectDefaults_IPList(obj.(*v1alpha1.IPList)) }) + return nil +} + +func SetObjectDefaults_IP(in *v1alpha1.IP) { + SetDefaults_IPSpec(&in.Spec) +} + +func SetObjectDefaults_IPList(in *v1alpha1.IPList) { + for i := range in.Items { + a := &in.Items[i] + SetObjectDefaults_IP(a) + } +} diff --git a/internal/apis/core/validation/daemonset.go b/internal/apis/core/validation/daemonset.go new file mode 100644 index 00000000..c5ea70b7 --- /dev/null +++ b/internal/apis/core/validation/daemonset.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateDaemonSet(daemonSet *core.DaemonSet) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(daemonSet, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateDaemonSetUpdate(newDaemonSet, oldDaemonSet *core.DaemonSet) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newDaemonSet, oldDaemonSet, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateDaemonSet(newDaemonSet)...) + + return allErrs +} + +func ValidateDaemonSetStatusUpdate(newDaemonSet, oldDaemonSet *core.DaemonSet) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newDaemonSet, oldDaemonSet, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/instance.go b/internal/apis/core/validation/instance.go new file mode 100644 index 00000000..17c16b30 --- /dev/null +++ b/internal/apis/core/validation/instance.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateInstance(instance *core.Instance) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(instance, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateInstanceUpdate(newInstance, oldInstance *core.Instance) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newInstance, oldInstance, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateInstance(newInstance)...) + + return allErrs +} + +func ValidateInstanceStatusUpdate(newInstance, oldInstance *core.Instance) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newInstance, oldInstance, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/ip.go b/internal/apis/core/validation/ip.go new file mode 100644 index 00000000..1f848afe --- /dev/null +++ b/internal/apis/core/validation/ip.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateIP(ip *core.IP) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(ip, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateIPUpdate(newIP, oldIP *core.IP) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newIP, oldIP, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateIP(newIP)...) + + return allErrs +} + +func ValidateIPStatusUpdate(newIP, oldIP *core.IP) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newIP, oldIP, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/ipaddress.go b/internal/apis/core/validation/ipaddress.go new file mode 100644 index 00000000..4698de0e --- /dev/null +++ b/internal/apis/core/validation/ipaddress.go @@ -0,0 +1,59 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "net/netip" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateIPAddressName(name string, prefix bool) []string { + var errs []string + ip, err := netip.ParseAddr(name) + if err != nil { + errs = append(errs, err.Error()) + } else if ip.String() != name { + errs = append(errs, "not a valid IP address in canonical format") + } + return errs +} + +func ValidateIPAddress(ipAddress *core.IPAddress) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(ipAddress, false, ValidateIPAddressName, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateIPAddressUpdate(newIPAddress, oldIPAddress *core.IPAddress) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newIPAddress, oldIPAddress, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateIPAddress(newIPAddress)...) + + return allErrs +} + +func ValidateIPAddressStatusUpdate(newIPAddress, oldIPAddress *core.IPAddress) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newIPAddress, oldIPAddress, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/loadbalancer.go b/internal/apis/core/validation/loadbalancer.go new file mode 100644 index 00000000..68e41740 --- /dev/null +++ b/internal/apis/core/validation/loadbalancer.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateLoadBalancer(loadBalancer *core.LoadBalancer) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(loadBalancer, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateLoadBalancerUpdate(newLoadBalancer, oldLoadBalancer *core.LoadBalancer) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newLoadBalancer, oldLoadBalancer, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateLoadBalancer(newLoadBalancer)...) + + return allErrs +} + +func ValidateLoadBalancerStatusUpdate(newLoadBalancer, oldLoadBalancer *core.LoadBalancer) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newLoadBalancer, oldLoadBalancer, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/loadbalancerrouting.go b/internal/apis/core/validation/loadbalancerrouting.go new file mode 100644 index 00000000..2d5c0f85 --- /dev/null +++ b/internal/apis/core/validation/loadbalancerrouting.go @@ -0,0 +1,38 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateLoadBalancerRouting(loadBalancerRouting *core.LoadBalancerRouting) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(loadBalancerRouting, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateLoadBalancerRoutingUpdate(newLoadBalancerRouting, oldLoadBalancerRouting *core.LoadBalancerRouting) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newLoadBalancerRouting, oldLoadBalancerRouting, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateLoadBalancerRouting(newLoadBalancerRouting)...) + + return allErrs +} diff --git a/internal/apis/core/validation/natgateway.go b/internal/apis/core/validation/natgateway.go new file mode 100644 index 00000000..a6579e58 --- /dev/null +++ b/internal/apis/core/validation/natgateway.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNATGateway(natGateway *core.NATGateway) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(natGateway, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNATGatewayUpdate(newNATGateway, oldNATGateway *core.NATGateway) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNATGateway, oldNATGateway, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNATGateway(newNATGateway)...) + + return allErrs +} + +func ValidateNATGatewayStatusUpdate(newNATGateway, oldNATGateway *core.NATGateway) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNATGateway, oldNATGateway, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/natgatewayautoscaler.go b/internal/apis/core/validation/natgatewayautoscaler.go new file mode 100644 index 00000000..3295dcab --- /dev/null +++ b/internal/apis/core/validation/natgatewayautoscaler.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNATGatewayAutoscaler(natGatewayAutoscaler *core.NATGatewayAutoscaler) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(natGatewayAutoscaler, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNATGatewayAutoscalerUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler *core.NATGatewayAutoscaler) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNATGatewayAutoscaler(newNATGatewayAutoscaler)...) + + return allErrs +} + +func ValidateNATGatewayAutoscalerStatusUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler *core.NATGatewayAutoscaler) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/nattable.go b/internal/apis/core/validation/nattable.go new file mode 100644 index 00000000..8e570987 --- /dev/null +++ b/internal/apis/core/validation/nattable.go @@ -0,0 +1,38 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNATTable(natTable *core.NATTable) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(natTable, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNATTableUpdate(newNATTable, oldNATTable *core.NATTable) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNATTable, oldNATTable, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNATTable(newNATTable)...) + + return allErrs +} diff --git a/internal/apis/core/validation/network.go b/internal/apis/core/validation/network.go new file mode 100644 index 00000000..65dab185 --- /dev/null +++ b/internal/apis/core/validation/network.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNetwork(network *core.Network) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(network, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNetworkUpdate(newNetwork, oldNetwork *core.Network) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNetwork, oldNetwork, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNetwork(newNetwork)...) + + return allErrs +} + +func ValidateNetworkStatusUpdate(newNetwork, oldNetwork *core.Network) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNetwork, oldNetwork, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/networkid.go b/internal/apis/core/validation/networkid.go new file mode 100644 index 00000000..ba499699 --- /dev/null +++ b/internal/apis/core/validation/networkid.go @@ -0,0 +1,50 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/networkid" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNetworkIDName(name string, prefix bool) []string { + var errs []string + vni, err := networkid.ParseVNI(name) + if err != nil { + errs = append(errs, err.Error()) + } else if networkid.EncodeVNI(vni) != name { + errs = append(errs, "not a valid VNI in canonical format") + } + return errs +} + +func ValidateNetworkID(networkID *core.NetworkID) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(networkID, false, ValidateNetworkIDName, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNetworkIDUpdate(newNetworkID, oldNetworkID *core.NetworkID) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNetworkID, oldNetworkID, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNetworkID(newNetworkID)...) + + return allErrs +} diff --git a/internal/apis/core/validation/networkinterface.go b/internal/apis/core/validation/networkinterface.go new file mode 100644 index 00000000..29bfe30c --- /dev/null +++ b/internal/apis/core/validation/networkinterface.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNetworkInterface(networkInterface *core.NetworkInterface) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(networkInterface, true, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNetworkInterfaceUpdate(newNetworkInterface, oldNetworkInterface *core.NetworkInterface) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNetworkInterface, oldNetworkInterface, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNetworkInterface(newNetworkInterface)...) + + return allErrs +} + +func ValidateNetworkInterfaceStatusUpdate(newNetworkInterface, oldNetworkInterface *core.NetworkInterface) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNetworkInterface, oldNetworkInterface, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/validation/node.go b/internal/apis/core/validation/node.go new file mode 100644 index 00000000..c04a0589 --- /dev/null +++ b/internal/apis/core/validation/node.go @@ -0,0 +1,46 @@ +// Copyright 2023 OnMetal 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 validation + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func ValidateNode(node *core.Node) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(node, false, validation.NameIsDNSLabel, field.NewPath("metadata"))...) + + return allErrs +} + +func ValidateNodeUpdate(newNode, oldNode *core.Node) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNode, oldNode, field.NewPath("metadata"))...) + allErrs = append(allErrs, ValidateNode(newNode)...) + + return allErrs +} + +func ValidateNodeStatusUpdate(newNode, oldNode *core.Node) field.ErrorList { + var allErrs field.ErrorList + + allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(newNode, oldNode, field.NewPath("metadata"))...) + + return allErrs +} diff --git a/internal/apis/core/well_known_annotations.go b/internal/apis/core/well_known_annotations.go new file mode 100644 index 00000000..bee1938e --- /dev/null +++ b/internal/apis/core/well_known_annotations.go @@ -0,0 +1,17 @@ +// Copyright 2023 OnMetal 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 core + +const () diff --git a/internal/apis/core/well_known_labels.go b/internal/apis/core/well_known_labels.go new file mode 100644 index 00000000..f700996d --- /dev/null +++ b/internal/apis/core/well_known_labels.go @@ -0,0 +1,22 @@ +// Copyright 2023 OnMetal 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 core + +const ( + ControllerRevisionHashLabel = "apinet.api.onmetal.de/controller-revision-hash" + + IPFamilyLabel = "apinet.api.onmetal.de/ip-family" + IPIPLabel = "apinet.api.onmetal.de/ip" +) diff --git a/internal/apis/core/zz_generated.deepcopy.go b/internal/apis/core/zz_generated.deepcopy.go new file mode 100644 index 00000000..7248a2b5 --- /dev/null +++ b/internal/apis/core/zz_generated.deepcopy.go @@ -0,0 +1,1806 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * Copyright (c) 2022 by the OnMetal 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 deepcopy-gen. DO NOT EDIT. + +package core + +import ( + net "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Affinity) DeepCopyInto(out *Affinity) { + *out = *in + if in.NodeAffinity != nil { + in, out := &in.NodeAffinity, &out.NodeAffinity + *out = new(NodeAffinity) + (*in).DeepCopyInto(*out) + } + if in.InstanceAntiAffinity != nil { + in, out := &in.InstanceAntiAffinity, &out.InstanceAntiAffinity + *out = new(InstanceAntiAffinity) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Affinity. +func (in *Affinity) DeepCopy() *Affinity { + if in == nil { + return nil + } + out := new(Affinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonSet) DeepCopyInto(out *DaemonSet) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSet. +func (in *DaemonSet) DeepCopy() *DaemonSet { + if in == nil { + return nil + } + out := new(DaemonSet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DaemonSet) 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 *DaemonSetList) DeepCopyInto(out *DaemonSetList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DaemonSet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetList. +func (in *DaemonSetList) DeepCopy() *DaemonSetList { + if in == nil { + return nil + } + out := new(DaemonSetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DaemonSetList) 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 *DaemonSetSpec) DeepCopyInto(out *DaemonSetSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetSpec. +func (in *DaemonSetSpec) DeepCopy() *DaemonSetSpec { + if in == nil { + return nil + } + out := new(DaemonSetSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonSetStatus) DeepCopyInto(out *DaemonSetStatus) { + *out = *in + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetStatus. +func (in *DaemonSetStatus) DeepCopy() *DaemonSetStatus { + if in == nil { + return nil + } + out := new(DaemonSetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IP) DeepCopyInto(out *IP) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IP. +func (in *IP) DeepCopy() *IP { + if in == nil { + return nil + } + out := new(IP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IP) 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 *IPAddress) DeepCopyInto(out *IPAddress) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// 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 *IPAddressClaimRef) DeepCopyInto(out *IPAddressClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressClaimRef. +func (in *IPAddressClaimRef) DeepCopy() *IPAddressClaimRef { + if in == nil { + return nil + } + out := new(IPAddressClaimRef) + in.DeepCopyInto(out) + return out +} + +// 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]) + } + } + return +} + +// 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 + in.IP.DeepCopyInto(&out.IP) + out.ClaimRef = in.ClaimRef + return +} + +// 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 *IPClaimRef) DeepCopyInto(out *IPClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimRef. +func (in *IPClaimRef) DeepCopy() *IPClaimRef { + if in == nil { + return nil + } + out := new(IPClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPList) DeepCopyInto(out *IPList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPList. +func (in *IPList) DeepCopy() *IPList { + if in == nil { + return nil + } + out := new(IPList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPList) 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 *IPSpec) DeepCopyInto(out *IPSpec) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.ClaimRef != nil { + in, out := &in.ClaimRef, &out.ClaimRef + *out = new(IPClaimRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPSpec. +func (in *IPSpec) DeepCopy() *IPSpec { + if in == nil { + return nil + } + out := new(IPSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPStatus) DeepCopyInto(out *IPStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPStatus. +func (in *IPStatus) DeepCopy() *IPStatus { + if in == nil { + return nil + } + out := new(IPStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Instance) DeepCopyInto(out *Instance) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instance. +func (in *Instance) DeepCopy() *Instance { + if in == nil { + return nil + } + out := new(Instance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Instance) 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 *InstanceAffinityTerm) DeepCopyInto(out *InstanceAffinityTerm) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceAffinityTerm. +func (in *InstanceAffinityTerm) DeepCopy() *InstanceAffinityTerm { + if in == nil { + return nil + } + out := new(InstanceAffinityTerm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceAntiAffinity) DeepCopyInto(out *InstanceAntiAffinity) { + *out = *in + if in.RequiredDuringSchedulingIgnoredDuringExecution != nil { + in, out := &in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution + *out = make([]InstanceAffinityTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceAntiAffinity. +func (in *InstanceAntiAffinity) DeepCopy() *InstanceAntiAffinity { + if in == nil { + return nil + } + out := new(InstanceAntiAffinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceList) DeepCopyInto(out *InstanceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Instance, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceList. +func (in *InstanceList) DeepCopy() *InstanceList { + if in == nil { + return nil + } + out := new(InstanceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstanceList) 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 *InstanceSpec) DeepCopyInto(out *InstanceSpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LoadBalancerPorts != nil { + in, out := &in.LoadBalancerPorts, &out.LoadBalancerPorts + *out = make([]LoadBalancerPort, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(Affinity) + (*in).DeepCopyInto(*out) + } + if in.TopologySpreadConstraints != nil { + in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints + *out = make([]TopologySpreadConstraint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NodeRef != nil { + in, out := &in.NodeRef, &out.NodeRef + *out = new(corev1.LocalObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSpec. +func (in *InstanceSpec) DeepCopy() *InstanceSpec { + if in == nil { + return nil + } + out := new(InstanceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { + *out = *in + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceStatus. +func (in *InstanceStatus) DeepCopy() *InstanceStatus { + if in == nil { + return nil + } + out := new(InstanceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstanceTemplate) DeepCopyInto(out *InstanceTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceTemplate. +func (in *InstanceTemplate) DeepCopy() *InstanceTemplate { + if in == nil { + return nil + } + out := new(InstanceTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancer) DeepCopyInto(out *LoadBalancer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancer. +func (in *LoadBalancer) DeepCopy() *LoadBalancer { + if in == nil { + return nil + } + out := new(LoadBalancer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancer) 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 *LoadBalancerDestination) DeepCopyInto(out *LoadBalancerDestination) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.TargetRef != nil { + in, out := &in.TargetRef, &out.TargetRef + *out = new(LoadBalancerTargetRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerDestination. +func (in *LoadBalancerDestination) DeepCopy() *LoadBalancerDestination { + if in == nil { + return nil + } + out := new(LoadBalancerDestination) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerIP) DeepCopyInto(out *LoadBalancerIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerIP. +func (in *LoadBalancerIP) DeepCopy() *LoadBalancerIP { + if in == nil { + return nil + } + out := new(LoadBalancerIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerList) DeepCopyInto(out *LoadBalancerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]LoadBalancer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerList. +func (in *LoadBalancerList) DeepCopy() *LoadBalancerList { + if in == nil { + return nil + } + out := new(LoadBalancerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerList) 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 *LoadBalancerPort) DeepCopyInto(out *LoadBalancerPort) { + *out = *in + if in.Protocol != nil { + in, out := &in.Protocol, &out.Protocol + *out = new(corev1.Protocol) + **out = **in + } + if in.EndPort != nil { + in, out := &in.EndPort, &out.EndPort + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerPort. +func (in *LoadBalancerPort) DeepCopy() *LoadBalancerPort { + if in == nil { + return nil + } + out := new(LoadBalancerPort) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerRouting) DeepCopyInto(out *LoadBalancerRouting) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Destinations != nil { + in, out := &in.Destinations, &out.Destinations + *out = make([]LoadBalancerDestination, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerRouting. +func (in *LoadBalancerRouting) DeepCopy() *LoadBalancerRouting { + if in == nil { + return nil + } + out := new(LoadBalancerRouting) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerRouting) 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 *LoadBalancerRoutingList) DeepCopyInto(out *LoadBalancerRoutingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]LoadBalancerRouting, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerRoutingList. +func (in *LoadBalancerRoutingList) DeepCopy() *LoadBalancerRoutingList { + if in == nil { + return nil + } + out := new(LoadBalancerRoutingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LoadBalancerRoutingList) 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 *LoadBalancerSpec) DeepCopyInto(out *LoadBalancerSpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]LoadBalancerIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Ports != nil { + in, out := &in.Ports, &out.Ports + *out = make([]LoadBalancerPort, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerSpec. +func (in *LoadBalancerSpec) DeepCopy() *LoadBalancerSpec { + if in == nil { + return nil + } + out := new(LoadBalancerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerStatus) DeepCopyInto(out *LoadBalancerStatus) { + *out = *in + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerStatus. +func (in *LoadBalancerStatus) DeepCopy() *LoadBalancerStatus { + if in == nil { + return nil + } + out := new(LoadBalancerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerTargetRef) DeepCopyInto(out *LoadBalancerTargetRef) { + *out = *in + out.NodeRef = in.NodeRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerTargetRef. +func (in *LoadBalancerTargetRef) DeepCopy() *LoadBalancerTargetRef { + if in == nil { + return nil + } + out := new(LoadBalancerTargetRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGateway) DeepCopyInto(out *NATGateway) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGateway. +func (in *NATGateway) DeepCopy() *NATGateway { + if in == nil { + return nil + } + out := new(NATGateway) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGateway) 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 *NATGatewayAutoscaler) DeepCopyInto(out *NATGatewayAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscaler. +func (in *NATGatewayAutoscaler) DeepCopy() *NATGatewayAutoscaler { + if in == nil { + return nil + } + out := new(NATGatewayAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayAutoscaler) 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 *NATGatewayAutoscalerList) DeepCopyInto(out *NATGatewayAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATGatewayAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerList. +func (in *NATGatewayAutoscalerList) DeepCopy() *NATGatewayAutoscalerList { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayAutoscalerList) 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 *NATGatewayAutoscalerSpec) DeepCopyInto(out *NATGatewayAutoscalerSpec) { + *out = *in + out.NATGatewayRef = in.NATGatewayRef + if in.MinPublicIPs != nil { + in, out := &in.MinPublicIPs, &out.MinPublicIPs + *out = new(int32) + **out = **in + } + if in.MaxPublicIPs != nil { + in, out := &in.MaxPublicIPs, &out.MaxPublicIPs + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerSpec. +func (in *NATGatewayAutoscalerSpec) DeepCopy() *NATGatewayAutoscalerSpec { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayAutoscalerStatus) DeepCopyInto(out *NATGatewayAutoscalerStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayAutoscalerStatus. +func (in *NATGatewayAutoscalerStatus) DeepCopy() *NATGatewayAutoscalerStatus { + if in == nil { + return nil + } + out := new(NATGatewayAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayIP) DeepCopyInto(out *NATGatewayIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayIP. +func (in *NATGatewayIP) DeepCopy() *NATGatewayIP { + if in == nil { + return nil + } + out := new(NATGatewayIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayList) DeepCopyInto(out *NATGatewayList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATGateway, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayList. +func (in *NATGatewayList) DeepCopy() *NATGatewayList { + if in == nil { + return nil + } + out := new(NATGatewayList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATGatewayList) 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 *NATGatewaySpec) DeepCopyInto(out *NATGatewaySpec) { + *out = *in + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]NATGatewayIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewaySpec. +func (in *NATGatewaySpec) DeepCopy() *NATGatewaySpec { + if in == nil { + return nil + } + out := new(NATGatewaySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATGatewayStatus) DeepCopyInto(out *NATGatewayStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATGatewayStatus. +func (in *NATGatewayStatus) DeepCopy() *NATGatewayStatus { + if in == nil { + return nil + } + out := new(NATGatewayStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATIP) DeepCopyInto(out *NATIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.Sections != nil { + in, out := &in.Sections, &out.Sections + *out = make([]NATIPSection, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATIP. +func (in *NATIP) DeepCopy() *NATIP { + if in == nil { + return nil + } + out := new(NATIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATIPSection) DeepCopyInto(out *NATIPSection) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + if in.TargetRef != nil { + in, out := &in.TargetRef, &out.TargetRef + *out = new(NATTableIPTargetRef) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATIPSection. +func (in *NATIPSection) DeepCopy() *NATIPSection { + if in == nil { + return nil + } + out := new(NATIPSection) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATTable) DeepCopyInto(out *NATTable) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]NATIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTable. +func (in *NATTable) DeepCopy() *NATTable { + if in == nil { + return nil + } + out := new(NATTable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATTable) 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 *NATTableIPTargetRef) DeepCopyInto(out *NATTableIPTargetRef) { + *out = *in + out.NodeRef = in.NodeRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTableIPTargetRef. +func (in *NATTableIPTargetRef) DeepCopy() *NATTableIPTargetRef { + if in == nil { + return nil + } + out := new(NATTableIPTargetRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NATTableList) DeepCopyInto(out *NATTableList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NATTable, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NATTableList. +func (in *NATTableList) DeepCopy() *NATTableList { + if in == nil { + return nil + } + out := new(NATTableList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NATTableList) 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 *Network) DeepCopyInto(out *Network) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Network. +func (in *Network) DeepCopy() *Network { + if in == nil { + return nil + } + out := new(Network) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Network) 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 *NetworkID) DeepCopyInto(out *NetworkID) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkID. +func (in *NetworkID) DeepCopy() *NetworkID { + if in == nil { + return nil + } + out := new(NetworkID) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkID) 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 *NetworkIDClaimRef) DeepCopyInto(out *NetworkIDClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDClaimRef. +func (in *NetworkIDClaimRef) DeepCopy() *NetworkIDClaimRef { + if in == nil { + return nil + } + out := new(NetworkIDClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkIDList) DeepCopyInto(out *NetworkIDList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NetworkID, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDList. +func (in *NetworkIDList) DeepCopy() *NetworkIDList { + if in == nil { + return nil + } + out := new(NetworkIDList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkIDList) 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 *NetworkIDSpec) DeepCopyInto(out *NetworkIDSpec) { + *out = *in + out.ClaimRef = in.ClaimRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkIDSpec. +func (in *NetworkIDSpec) DeepCopy() *NetworkIDSpec { + if in == nil { + return nil + } + out := new(NetworkIDSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterface) DeepCopyInto(out *NetworkInterface) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterface. +func (in *NetworkInterface) DeepCopy() *NetworkInterface { + if in == nil { + return nil + } + out := new(NetworkInterface) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkInterface) 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 *NetworkInterfaceList) DeepCopyInto(out *NetworkInterfaceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NetworkInterface, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceList. +func (in *NetworkInterfaceList) DeepCopy() *NetworkInterfaceList { + if in == nil { + return nil + } + out := new(NetworkInterfaceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkInterfaceList) 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 *NetworkInterfaceNAT) DeepCopyInto(out *NetworkInterfaceNAT) { + *out = *in + out.ClaimRef = in.ClaimRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceNAT. +func (in *NetworkInterfaceNAT) DeepCopy() *NetworkInterfaceNAT { + if in == nil { + return nil + } + out := new(NetworkInterfaceNAT) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceNATClaimRef) DeepCopyInto(out *NetworkInterfaceNATClaimRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceNATClaimRef. +func (in *NetworkInterfaceNATClaimRef) DeepCopy() *NetworkInterfaceNATClaimRef { + if in == nil { + return nil + } + out := new(NetworkInterfaceNATClaimRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfacePublicIP) DeepCopyInto(out *NetworkInterfacePublicIP) { + *out = *in + in.IP.DeepCopyInto(&out.IP) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfacePublicIP. +func (in *NetworkInterfacePublicIP) DeepCopy() *NetworkInterfacePublicIP { + if in == nil { + return nil + } + out := new(NetworkInterfacePublicIP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceSpec) DeepCopyInto(out *NetworkInterfaceSpec) { + *out = *in + out.NodeRef = in.NodeRef + out.NetworkRef = in.NetworkRef + if in.IPs != nil { + in, out := &in.IPs, &out.IPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Prefixes != nil { + in, out := &in.Prefixes, &out.Prefixes + *out = make([]net.IPPrefix, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NATs != nil { + in, out := &in.NATs, &out.NATs + *out = make([]NetworkInterfaceNAT, len(*in)) + copy(*out, *in) + } + if in.PublicIPs != nil { + in, out := &in.PublicIPs, &out.PublicIPs + *out = make([]NetworkInterfacePublicIP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceSpec. +func (in *NetworkInterfaceSpec) DeepCopy() *NetworkInterfaceSpec { + if in == nil { + return nil + } + out := new(NetworkInterfaceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkInterfaceStatus) DeepCopyInto(out *NetworkInterfaceStatus) { + *out = *in + if in.PCIAddress != nil { + in, out := &in.PCIAddress, &out.PCIAddress + *out = new(PCIAddress) + **out = **in + } + if in.Prefixes != nil { + in, out := &in.Prefixes, &out.Prefixes + *out = make([]net.IPPrefix, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PublicIPs != nil { + in, out := &in.PublicIPs, &out.PublicIPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NATIPs != nil { + in, out := &in.NATIPs, &out.NATIPs + *out = make([]net.IP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceStatus. +func (in *NetworkInterfaceStatus) DeepCopy() *NetworkInterfaceStatus { + if in == nil { + return nil + } + out := new(NetworkInterfaceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkList) DeepCopyInto(out *NetworkList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Network, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkList. +func (in *NetworkList) DeepCopy() *NetworkList { + if in == nil { + return nil + } + out := new(NetworkList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkList) 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 *NetworkSpec) DeepCopyInto(out *NetworkSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. +func (in *NetworkSpec) DeepCopy() *NetworkSpec { + if in == nil { + return nil + } + out := new(NetworkSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. +func (in *NetworkStatus) DeepCopy() *NetworkStatus { + if in == nil { + return nil + } + out := new(NetworkStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Node) DeepCopyInto(out *Node) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node. +func (in *Node) DeepCopy() *Node { + if in == nil { + return nil + } + out := new(Node) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Node) 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 *NodeAffinity) DeepCopyInto(out *NodeAffinity) { + *out = *in + if in.RequiredDuringSchedulingIgnoredDuringExecution != nil { + in, out := &in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution + *out = new(NodeSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeAffinity. +func (in *NodeAffinity) DeepCopy() *NodeAffinity { + if in == nil { + return nil + } + out := new(NodeAffinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeList) DeepCopyInto(out *NodeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Node, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeList. +func (in *NodeList) DeepCopy() *NodeList { + if in == nil { + return nil + } + out := new(NodeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeList) 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 *NodeSelector) DeepCopyInto(out *NodeSelector) { + *out = *in + if in.NodeSelectorTerms != nil { + in, out := &in.NodeSelectorTerms, &out.NodeSelectorTerms + *out = make([]NodeSelectorTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelector. +func (in *NodeSelector) DeepCopy() *NodeSelector { + if in == nil { + return nil + } + out := new(NodeSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSelectorRequirement) DeepCopyInto(out *NodeSelectorRequirement) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelectorRequirement. +func (in *NodeSelectorRequirement) DeepCopy() *NodeSelectorRequirement { + if in == nil { + return nil + } + out := new(NodeSelectorRequirement) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSelectorTerm) DeepCopyInto(out *NodeSelectorTerm) { + *out = *in + if in.MatchExpressions != nil { + in, out := &in.MatchExpressions, &out.MatchExpressions + *out = make([]NodeSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.MatchFields != nil { + in, out := &in.MatchFields, &out.MatchFields + *out = make([]NodeSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSelectorTerm. +func (in *NodeSelectorTerm) DeepCopy() *NodeSelectorTerm { + if in == nil { + return nil + } + out := new(NodeSelectorTerm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeSpec. +func (in *NodeSpec) DeepCopy() *NodeSpec { + if in == nil { + return nil + } + out := new(NodeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatus) DeepCopyInto(out *NodeStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatus. +func (in *NodeStatus) DeepCopy() *NodeStatus { + if in == nil { + return nil + } + out := new(NodeStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PCIAddress) DeepCopyInto(out *PCIAddress) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PCIAddress. +func (in *PCIAddress) DeepCopy() *PCIAddress { + if in == nil { + return nil + } + out := new(PCIAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TopologySpreadConstraint) DeepCopyInto(out *TopologySpreadConstraint) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopologySpreadConstraint. +func (in *TopologySpreadConstraint) DeepCopy() *TopologySpreadConstraint { + if in == nil { + return nil + } + out := new(TopologySpreadConstraint) + in.DeepCopyInto(out) + return out +} diff --git a/internal/apiserver/apiserver.go b/internal/apiserver/apiserver.go new file mode 100644 index 00000000..c9ca1372 --- /dev/null +++ b/internal/apiserver/apiserver.go @@ -0,0 +1,285 @@ +// Copyright 2022 OnMetal 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 apiserver + +import ( + "net/netip" + + "github.com/onmetal/onmetal-api-net/apimachinery/equality" + "github.com/onmetal/onmetal-api-net/client-go/informers" + v1alpha1client "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/install" + "github.com/onmetal/onmetal-api-net/internal/registry/daemonset" + "github.com/onmetal/onmetal-api-net/internal/registry/instance" + "github.com/onmetal/onmetal-api-net/internal/registry/ip" + "github.com/onmetal/onmetal-api-net/internal/registry/ip/ipaddressallocator" + "github.com/onmetal/onmetal-api-net/internal/registry/ipaddress" + "github.com/onmetal/onmetal-api-net/internal/registry/ipallocator" + "github.com/onmetal/onmetal-api-net/internal/registry/loadbalancer" + "github.com/onmetal/onmetal-api-net/internal/registry/loadbalancerrouting" + "github.com/onmetal/onmetal-api-net/internal/registry/natgateway" + "github.com/onmetal/onmetal-api-net/internal/registry/natgatewayautoscaler" + "github.com/onmetal/onmetal-api-net/internal/registry/nattable" + "github.com/onmetal/onmetal-api-net/internal/registry/network" + "github.com/onmetal/onmetal-api-net/internal/registry/network/networkidallocator" + "github.com/onmetal/onmetal-api-net/internal/registry/networkid" + "github.com/onmetal/onmetal-api-net/internal/registry/networkinterface" + "github.com/onmetal/onmetal-api-net/internal/registry/node" + corev1 "k8s.io/api/core/v1" + apimachineryequality "k8s.io/apimachinery/pkg/api/equality" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/version" + "k8s.io/apiserver/pkg/registry/rest" + genericapiserver "k8s.io/apiserver/pkg/server" +) + +var ( + Scheme = runtime.NewScheme() + Codecs = serializer.NewCodecFactory(Scheme) +) + +func init() { + utilruntime.Must(equality.AddFuncs(apimachineryequality.Semantic)) + + install.Install(Scheme) + + metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + unversioned := schema.GroupVersion{Group: "", Version: "v1"} + Scheme.AddUnversionedTypes(unversioned, + &metav1.Status{}, + &metav1.APIVersions{}, + &metav1.APIGroupList{}, + &metav1.APIGroup{}, + &metav1.APIResourceList{}, + ) +} + +// ExtraConfig holds custom apiserver config +type ExtraConfig struct { + MinVNI int32 + MaxVNI int32 + + PublicPrefix []netip.Prefix + + VersionedInformers informers.SharedInformerFactory +} + +// Config defines the config for the apiserver +type Config struct { + GenericConfig *genericapiserver.RecommendedConfig + ExtraConfig ExtraConfig +} + +// OnmetalAPIServer contains state for a Kubernetes cluster master/api server. +type OnmetalAPIServer struct { + GenericAPIServer *genericapiserver.GenericAPIServer +} + +type completedConfig struct { + GenericConfig genericapiserver.CompletedConfig + ExtraConfig *ExtraConfig +} + +// CompletedConfig embeds a private pointer that cannot be instantiated outside of this package. +type CompletedConfig struct { + *completedConfig +} + +// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. +func (cfg *Config) Complete() CompletedConfig { + c := completedConfig{ + cfg.GenericConfig.Complete(), + &cfg.ExtraConfig, + } + + c.GenericConfig.Version = &version.Info{ + Major: "1", + Minor: "0", + } + + return CompletedConfig{&c} +} + +// New returns a new instance of OnmetalAPIServer from the given config. +func (c completedConfig) New() (*OnmetalAPIServer, error) { + genericServer, err := c.GenericConfig.New("onmetal-api-net-apiserver", genericapiserver.NewEmptyDelegate()) + if err != nil { + return nil, err + } + + v1alpha1Client, err := v1alpha1client.NewForConfig(c.GenericConfig.LoopbackClientConfig) + if err != nil { + return nil, err + } + + ipAddrAllocByFamily := make(map[corev1.IPFamily]ipaddressallocator.Interface) + ipAllocByFamily := make(map[corev1.IPFamily]ipallocator.Interface) + + for _, publicPrefix := range c.ExtraConfig.PublicPrefix { + ipAddrAlloc, err := ipaddressallocator.New( + publicPrefix, + v1alpha1Client, + c.ExtraConfig.VersionedInformers.Core().V1alpha1().IPAddresses(), + ) + if err != nil { + return nil, err + } + + ipAlloc, err := ipallocator.New( + publicPrefix, + v1alpha1Client, + c.ExtraConfig.VersionedInformers.Core().V1alpha1().IPs(), + ) + if err != nil { + return nil, err + } + + ipAddrAllocByFamily[ipAddrAlloc.IPFamily()] = ipAddrAlloc + ipAllocByFamily[ipAlloc.IPFamily()] = ipAlloc + } + + networkIDAllocator, err := networkidallocator.NewNetworkIDAllocator( + v1alpha1Client, + c.ExtraConfig.VersionedInformers.Core().V1alpha1().NetworkIDs(), + c.ExtraConfig.MinVNI, + c.ExtraConfig.MaxVNI, + ) + if err != nil { + return nil, err + } + + s := &OnmetalAPIServer{ + GenericAPIServer: genericServer, + } + + apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(core.GroupName, Scheme, metav1.ParameterCodec, Codecs) + v1alpha1storage := make(map[string]rest.Storage) + + daemonSetStorage, err := daemonset.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["daemonsets"] = daemonSetStorage.DaemonSet + v1alpha1storage["daemonsets/status"] = daemonSetStorage.Status + + instanceStorage, err := instance.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["instances"] = instanceStorage.Instance + v1alpha1storage["instances/status"] = instanceStorage.Status + + ipStorage, err := ip.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter, ipAddrAllocByFamily) + if err != nil { + return nil, err + } + + v1alpha1storage["ips"] = ipStorage.IP + + ipAddressStorage, err := ipaddress.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["ipaddresses"] = ipAddressStorage.IPAddress + + loadBalancerStorage, err := loadbalancer.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter, ipAllocByFamily) + if err != nil { + return nil, err + } + + v1alpha1storage["loadbalancers"] = loadBalancerStorage.LoadBalancer + v1alpha1storage["loadbalancers/status"] = loadBalancerStorage.Status + + loadBalancerRoutingStorage, err := loadbalancerrouting.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["loadbalancerroutings"] = loadBalancerRoutingStorage.LoadBalancerRouting + + natGatewayStorage, err := natgateway.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter, ipAllocByFamily) + if err != nil { + return nil, err + } + + v1alpha1storage["natgateways"] = natGatewayStorage.NATGateway + v1alpha1storage["natgateways/status"] = natGatewayStorage.Status + + natGatewayAutoscalerStorage, err := natgatewayautoscaler.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["natgatewayautoscalers"] = natGatewayAutoscalerStorage.NATGatewayAutoscaler + v1alpha1storage["natgatewayautoscalers/status"] = natGatewayAutoscalerStorage.Status + + natTableStorage, err := nattable.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["nattables"] = natTableStorage.NATTable + + networkStorage, err := network.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter, networkIDAllocator) + if err != nil { + return nil, err + } + + v1alpha1storage["networks"] = networkStorage.Network + v1alpha1storage["networks/status"] = networkStorage.Status + + networkIDStorage, err := networkid.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["networkids"] = networkIDStorage.NetworkID + + networkInterfaceStorage, err := networkinterface.NewStorage( + Scheme, + c.GenericConfig.RESTOptionsGetter, + ipAllocByFamily, + ) + if err != nil { + return nil, err + } + + v1alpha1storage["networkinterfaces"] = networkInterfaceStorage.NetworkInterface + v1alpha1storage["networkinterfaces/status"] = networkInterfaceStorage.Status + + nodeStorage, err := node.NewStorage(Scheme, c.GenericConfig.RESTOptionsGetter) + if err != nil { + return nil, err + } + + v1alpha1storage["nodes"] = nodeStorage.Node + v1alpha1storage["nodes/status"] = nodeStorage.Status + + apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage + + if err := s.GenericAPIServer.InstallAPIGroups(&apiGroupInfo); err != nil { + return nil, err + } + + return s, nil +} diff --git a/internal/app/apiserver/apiserver.go b/internal/app/apiserver/apiserver.go new file mode 100644 index 00000000..0c1547cc --- /dev/null +++ b/internal/app/apiserver/apiserver.go @@ -0,0 +1,179 @@ +// Copyright 2023 OnMetal 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 apiserver + +import ( + "context" + "fmt" + "net" + "net/netip" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/client-go/informers" + clientset "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet" + apinetopenapi "github.com/onmetal/onmetal-api-net/client-go/openapi" + netflag "github.com/onmetal/onmetal-api-net/flag" + "github.com/onmetal/onmetal-api-net/internal/apiserver" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + utilerrors "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apiserver/pkg/admission" + "k8s.io/apiserver/pkg/endpoints/openapi" + "k8s.io/apiserver/pkg/features" + genericapiserver "k8s.io/apiserver/pkg/server" + "k8s.io/apiserver/pkg/server/options" + utilfeature "k8s.io/apiserver/pkg/util/feature" + netutils "k8s.io/utils/net" +) + +const ( + defaultEtcdPathPrefix = "/registry/apinet.onmetal.de" + + defaultMinVNI = 200 + defaultMaxVNI = (1 << 24) - 1 +) + +type OnmetalAPINetServerOptions struct { + RecommendedOptions *options.RecommendedOptions + SharedInformerFactory informers.SharedInformerFactory + MinVNI int32 + MaxVNI int32 + PublicPrefix []netip.Prefix +} + +func (o *OnmetalAPINetServerOptions) AddFlags(fs *pflag.FlagSet) { + o.RecommendedOptions.AddFlags(fs) + fs.Int32Var(&o.MinVNI, "min-vni", o.MinVNI, "Minimum VNI to allocate") + fs.Int32Var(&o.MaxVNI, "max-vni", o.MaxVNI, "Maximum VNI to allocate") + netflag.IPPrefixesVar(fs, &o.PublicPrefix, "public-prefix", o.PublicPrefix, "Public prefixes to allocate from") +} + +func NewOnmetalAPINetServerOptions() *OnmetalAPINetServerOptions { + o := &OnmetalAPINetServerOptions{ + RecommendedOptions: options.NewRecommendedOptions( + defaultEtcdPathPrefix, + apiserver.Codecs.LegacyCodec(v1alpha1.SchemeGroupVersion), + ), + MinVNI: defaultMinVNI, + MaxVNI: defaultMaxVNI, + } + o.RecommendedOptions.Etcd.StorageConfig.EncodeVersioner = runtime.NewMultiGroupVersioner(v1alpha1.SchemeGroupVersion, schema.GroupKind{Group: v1alpha1.GroupName}) + return o +} + +func NewCommandStartOnmetalAPINetServer(ctx context.Context, defaults *OnmetalAPINetServerOptions) *cobra.Command { + o := *defaults + cmd := &cobra.Command{ + Short: "Launch an onmetal-api-net API server", + Long: "Launch an onmetal-api-net API server", + RunE: func(cmd *cobra.Command, args []string) error { + if err := o.Complete(); err != nil { + return err + } + if err := o.Validate(args); err != nil { + return err + } + if err := o.Run(ctx); err != nil { + return err + } + return nil + }, + } + + o.AddFlags(cmd.Flags()) + utilfeature.DefaultMutableFeatureGate.AddFlag(cmd.Flags()) + + return cmd +} + +func (o *OnmetalAPINetServerOptions) Validate(args []string) error { + var errs []error + errs = append(errs, o.RecommendedOptions.Validate()...) + return utilerrors.NewAggregate(errs) +} + +func (o *OnmetalAPINetServerOptions) Complete() error { + return nil +} + +func (o *OnmetalAPINetServerOptions) Config() (*apiserver.Config, error) { + if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{netutils.ParseIPSloppy("127.0.0.1")}); err != nil { + return nil, fmt.Errorf("error creating self-signed certificates: %w", err) + } + + o.RecommendedOptions.Etcd.StorageConfig.Paging = utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking) + + o.RecommendedOptions.ExtraAdmissionInitializers = func(c *genericapiserver.RecommendedConfig) ([]admission.PluginInitializer, error) { + onmetalAPINetClient, err := clientset.NewForConfig(c.LoopbackClientConfig) + if err != nil { + return nil, err + } + + informerFactory := informers.NewSharedInformerFactory(onmetalAPINetClient, c.LoopbackClientConfig.Timeout) + o.SharedInformerFactory = informerFactory + + return nil, nil + } + + serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs) + + serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(apinetopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) + serverConfig.OpenAPIConfig.Info.Title = "onmetal-api-net" + serverConfig.OpenAPIConfig.Info.Version = "0.1" + + if utilfeature.DefaultFeatureGate.Enabled(features.OpenAPIV3) { + serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIConfig(apinetopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) + serverConfig.OpenAPIV3Config.Info.Title = "onmetal-api-net" + serverConfig.OpenAPIV3Config.Info.Version = "0.1" + } + + if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil { + return nil, err + } + + config := &apiserver.Config{ + GenericConfig: serverConfig, + ExtraConfig: apiserver.ExtraConfig{ + MinVNI: o.MinVNI, + MaxVNI: o.MaxVNI, + PublicPrefix: o.PublicPrefix, + VersionedInformers: o.SharedInformerFactory, + }, + } + + return config, nil +} + +func (o *OnmetalAPINetServerOptions) Run(ctx context.Context) error { + config, err := o.Config() + if err != nil { + return err + } + + server, err := config.Complete().New() + if err != nil { + return err + } + + server.GenericAPIServer.AddPostStartHookOrDie("start-onmetal-api-net-server-informers", func(context genericapiserver.PostStartHookContext) error { + config.GenericConfig.SharedInformerFactory.Start(context.StopCh) + o.SharedInformerFactory.Start(context.StopCh) + return nil + }) + + return server.GenericAPIServer.PrepareRun().Run(ctx.Done()) +} diff --git a/internal/app/app_suite_test.go b/internal/app/app_suite_test.go new file mode 100644 index 00000000..f9fb06c6 --- /dev/null +++ b/internal/app/app_suite_test.go @@ -0,0 +1,109 @@ +/* +Copyright 2022 The Metal 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 app_test + +import ( + "path/filepath" + "testing" + "time" + + "github.com/onmetal/controller-utils/buildutils" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + utilsenvtest "github.com/onmetal/onmetal-api/utils/envtest" + "github.com/onmetal/onmetal-api/utils/envtest/apiserver" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" + logf "sigs.k8s.io/controller-runtime/pkg/log" + //+kubebuilder:scaffold:imports +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var ( + cfg *rest.Config + k8sClient client.Client + testEnv *envtest.Environment + testEnvExt *utilsenvtest.EnvironmentExtensions +) + +const ( + pollingInterval = 50 * time.Millisecond + eventuallyTimeout = 3 * time.Second + consistentlyDuration = 1 * time.Second + apiServiceTimeout = 1 * time.Minute +) + +func TestControllers(t *testing.T) { + SetDefaultConsistentlyPollingInterval(pollingInterval) + SetDefaultEventuallyPollingInterval(pollingInterval) + SetDefaultEventuallyTimeout(eventuallyTimeout) + SetDefaultConsistentlyDuration(consistentlyDuration) + + RegisterFailHandler(Fail) + + RunSpecs(t, "Controller Suite") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(GinkgoLogr) + + var err error + + By("bootstrapping test environment") + testEnv = &envtest.Environment{} + testEnvExt = &utilsenvtest.EnvironmentExtensions{ + APIServiceDirectoryPaths: []string{filepath.Join("..", "..", "config", "apiserver", "apiservice", "bases")}, + ErrorIfAPIServicePathIsMissing: true, + } + + cfg, err = utilsenvtest.StartWithExtensions(testEnv, testEnvExt) + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + DeferCleanup(utilsenvtest.StopWithExtensions, testEnv, testEnvExt) + + Expect(v1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + SetClient(k8sClient) + + apiSrv, err := apiserver.New(cfg, apiserver.Options{ + MainPath: "github.com/onmetal/onmetal-api-net/cmd/apiserver", + BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, + ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, + Host: testEnvExt.APIServiceInstallOptions.LocalServingHost, + Port: testEnvExt.APIServiceInstallOptions.LocalServingPort, + CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir, + Args: apiserver.ProcessArgs{ + "public-prefix": []string{"10.0.0.0/24"}, + }, + }) + Expect(err).NotTo(HaveOccurred()) + + Expect(apiSrv.Start()).To(Succeed()) + DeferCleanup(apiSrv.Stop) + + Expect(utilsenvtest.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed()) +}) diff --git a/internal/app/core_test.go b/internal/app/core_test.go new file mode 100644 index 00000000..3f6f7123 --- /dev/null +++ b/internal/app/core_test.go @@ -0,0 +1,314 @@ +// Copyright 2023 OnMetal 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 app_test + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + . "github.com/onmetal/onmetal-api-net/utils/testing" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("Core", func() { + ns := SetupNamespace(&k8sClient) + + Context("Network", func() { + It("should maintain network ID allocations for networks", func(ctx SpecContext) { + By("creating a network") + network := &v1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "network-", + }, + } + Expect(k8sClient.Create(ctx, network)).To(Succeed()) + + By("inspecting the network for its ID") + Expect(network.Spec.ID).NotTo(BeEmpty()) + + By("retrieving the corresponding network ID") + networkID := &v1alpha1.NetworkID{} + networkIDKey := client.ObjectKey{Name: network.Spec.ID} + Expect(k8sClient.Get(ctx, networkIDKey, networkID)).To(Succeed()) + + By("inspecting the network ID") + Expect(networkID.Spec.ClaimRef).To(Equal(v1alpha1.NetworkIDClaimRef{ + Group: v1alpha1.GroupName, + Resource: "networks", + Namespace: network.Namespace, + Name: network.Name, + UID: network.UID, + })) + + By("deleting the network") + Expect(k8sClient.Delete(ctx, network)).To(Succeed()) + + By("asserting the corresponding network ID is gone") + Expect(k8sClient.Get(ctx, networkIDKey, networkID)).To(Satisfy(apierrors.IsNotFound)) + }) + }) + + Context("IP", func() { + It("should maintain IP address allocations for IPs", func(ctx SpecContext) { + By("creating an IP") + ip := &v1alpha1.IP{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "ip-", + }, + Spec: v1alpha1.IPSpec{ + IPFamily: corev1.IPv4Protocol, + }, + } + Expect(k8sClient.Create(ctx, ip)).To(Succeed()) + + By("inspecting the IP for its address") + Expect(&ip.Spec.IP).To(Satisfy((*net.IP).IsValid)) + + By("retrieving the corresponding IP address") + ipAddress := &v1alpha1.IPAddress{} + ipAddressKey := client.ObjectKey{Name: ip.Spec.IP.String()} + Expect(k8sClient.Get(ctx, ipAddressKey, ipAddress)).To(Succeed()) + + By("inspecting the IP address") + Expect(ipAddress.Spec.ClaimRef).To(Equal(v1alpha1.IPAddressClaimRef{ + Group: v1alpha1.GroupName, + Resource: "ips", + Namespace: ip.Namespace, + Name: ip.Name, + UID: ip.UID, + })) + + By("deleting the IP") + Expect(k8sClient.Delete(ctx, ip)).To(Succeed()) + + By("asserting the corresponding IP address is gone") + Expect(k8sClient.Get(ctx, ipAddressKey, ipAddress)).To(Satisfy(apierrors.IsNotFound)) + }) + }) + + Context("LoadBalancer", func() { + It("should maintain IP allocations for load balancers", func(ctx SpecContext) { + By("creating a load balancer") + loadBalancer := &v1alpha1.LoadBalancer{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-", + }, + Spec: v1alpha1.LoadBalancerSpec{ + Type: v1alpha1.LoadBalancerTypePublic, + NetworkRef: corev1.LocalObjectReference{Name: "my-network"}, + IPs: []v1alpha1.LoadBalancerIP{ + { + Name: "ip-1", + IPFamily: corev1.IPv4Protocol, + }, + }, + }, + } + Expect(k8sClient.Create(ctx, loadBalancer)).To(Succeed()) + + By("inspecting the load balancer for its IPs") + var ip net.IP + Expect(loadBalancer.Spec.IPs).To(ConsistOf( + HaveField("IP", Capture(&ip, AsRef(Satisfy((*net.IP).IsValid)))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", ip), + ))) + + By("updating the load balancer IPs") + Eventually(Update(loadBalancer, func() { + loadBalancer.Spec.IPs = []v1alpha1.LoadBalancerIP{ + { + Name: "new-ip-1", + IPFamily: corev1.IPv4Protocol, + }, + } + })).Should(Succeed()) + + By("inspecting the load balancer IPs") + var newIP net.IP + Expect(loadBalancer.Spec.IPs).To(ConsistOf( + HaveField("IP", Capture(&newIP, SatisfyAll( + Not(Equal(ip)), + AsRef(Satisfy((*net.IP).IsValid)), + ))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", newIP), + ))) + + By("deleting the load balancer") + Expect(k8sClient.Delete(ctx, loadBalancer)).To(Succeed()) + + By("asserting there are no IPs") + Expect(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )()).To(HaveField("Items", BeEmpty())) + }) + }) + + Context("NATGateway", func() { + It("should maintain IP allocations for NAT gateways", func(ctx SpecContext) { + By("creating a NAT gateway") + natGateway := &v1alpha1.NATGateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-", + }, + Spec: v1alpha1.NATGatewaySpec{ + NetworkRef: corev1.LocalObjectReference{Name: "foo"}, + IPFamily: corev1.IPv4Protocol, + IPs: []v1alpha1.NATGatewayIP{ + { + Name: "ip-1", + }, + }, + }, + } + Expect(k8sClient.Create(ctx, natGateway)).To(Succeed()) + + By("inspecting the NAT gateway for its IPs") + var ip net.IP + Expect(natGateway.Spec.IPs).To(ConsistOf( + HaveField("IP", Capture(&ip, AsRef(Satisfy((*net.IP).IsValid)))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", ip), + ))) + + By("updating the NAT gateway IPs") + Eventually(Update(natGateway, func() { + natGateway.Spec.IPs = []v1alpha1.NATGatewayIP{ + { + Name: "new-ip-1", + }, + } + })).Should(Succeed()) + + By("inspecting the NAT gateway IPs") + var newIP net.IP + Expect(natGateway.Spec.IPs).To(ConsistOf( + HaveField("IP", Capture(&newIP, SatisfyAll( + Not(Equal(ip)), + AsRef(Satisfy((*net.IP).IsValid)), + ))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", newIP), + ))) + + By("deleting the NAT gateway") + Expect(k8sClient.Delete(ctx, natGateway)).To(Succeed()) + + By("asserting there are no IPs") + Expect(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )()).To(HaveField("Items", BeEmpty())) + }) + }) + + Context("NetworkInterface", func() { + It("should maintain IP allocations for network interfaces", func(ctx SpecContext) { + By("creating a network interface") + networkInterface := &v1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-", + }, + Spec: v1alpha1.NetworkInterfaceSpec{ + PublicIPs: []v1alpha1.NetworkInterfacePublicIP{ + { + Name: "ip-1", + IPFamily: corev1.IPv4Protocol, + }, + }, + }, + } + Expect(k8sClient.Create(ctx, networkInterface)).To(Succeed()) + + By("inspecting the network interface for its IPs") + var ip net.IP + Expect(networkInterface.Spec.PublicIPs).To(ConsistOf( + HaveField("IP", Capture(&ip, AsRef(Satisfy((*net.IP).IsValid)))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", ip), + ))) + + By("updating the network interface IPs") + Eventually(Update(networkInterface, func() { + networkInterface.Spec.PublicIPs = []v1alpha1.NetworkInterfacePublicIP{ + { + Name: "new-ip-1", + IPFamily: corev1.IPv4Protocol, + }, + } + })).Should(Succeed()) + + By("inspecting the network interface IPs") + var newIP net.IP + Expect(networkInterface.Spec.PublicIPs).To(ConsistOf( + HaveField("IP", Capture(&newIP, SatisfyAll( + Not(Equal(ip)), + AsRef(Satisfy((*net.IP).IsValid)), + ))), + )) + + By("retrieving the corresponding IP") + Eventually(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", newIP), + ))) + + By("deleting the network interface") + Expect(k8sClient.Delete(ctx, networkInterface)).To(Succeed()) + + By("asserting there are no IPs") + Expect(ObjectList(&v1alpha1.IPList{}, + client.InNamespace(ns.Name), + )()).To(HaveField("Items", BeEmpty())) + }) + }) +}) diff --git a/internal/client/client.go b/internal/client/client.go new file mode 100644 index 00000000..9a9852fb --- /dev/null +++ b/internal/client/client.go @@ -0,0 +1,139 @@ +// Copyright 2023 OnMetal 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 client + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/util/retry" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func ClaimNetworkInterfaceNAT( + ctx context.Context, + c client.Client, + nic *v1alpha1.NetworkInterface, + ipFamily corev1.IPFamily, + claimRef v1alpha1.NetworkInterfaceNATClaimRef, +) error { + if existing := v1alpha1.GetNetworkInterfaceNATClaimer(nic, ipFamily); existing != nil { + return fmt.Errorf("cannot claim a claimed network interface") + } + + var ( + key = client.ObjectKeyFromObject(nic) + uid = nic.UID + needGet bool + newConflict = func() error { + return apierrors.NewConflict(schema.GroupResource{ + Group: v1alpha1.GroupName, + Resource: "networkinterfaces", + }, key.Name, fmt.Errorf("network interface has been modified, please modify and reapply your changes")) + } + lastErr error + ) + err := wait.ExponentialBackoff(retry.DefaultRetry, func() (done bool, err error) { + if needGet { + if err := c.Get(ctx, key, nic); err != nil { + return false, err + } + } + needGet = true + + if nic.UID != uid { + return false, newConflict() + } + if existing := v1alpha1.GetNetworkInterfaceNATClaimer(nic, ipFamily); existing != nil { + if *existing == claimRef { + // Somehow it was claimed correctly - take it as it is. + return true, nil + } + + // Taken by different claimer in the meantime. + return false, newConflict() + } + + base := nic.DeepCopy() + nic.Spec.NATs = append(nic.Spec.NATs, v1alpha1.NetworkInterfaceNAT{IPFamily: ipFamily, ClaimRef: claimRef}) + if err := c.Patch(ctx, nic, client.MergeFromWithOptions(base, &client.MergeFromWithOptimisticLock{})); err != nil { + if !apierrors.IsConflict(err) { + // No conflict - return immediately. + return false, err + } + + lastErr = err + return false, nil + } + // Successfully patched and claimed. + return true, nil + }) + if wait.Interrupted(err) { + return lastErr + } + return err +} + +// ReleaseNetworkInterfaceNAT releases an IP address NAT. +// Since we use CRDs, we unfortunately cannot implement a custom 'release-Verb' that would handle +// the correct release procedure in the API server. To work around this, this method acts on the conflict +// that might arise when deleting / patching the network interface. +func ReleaseNetworkInterfaceNAT(ctx context.Context, c client.Client, nic *v1alpha1.NetworkInterface, ipFamily corev1.IPFamily) error { + existing := v1alpha1.GetNetworkInterfaceNATClaimer(nic, ipFamily) + if existing == nil { + // Short circuit if no claim ref is specified. + return nil + } + + // Store key, UID and claim ref in order not to alter any other IP address. + var ( + key = client.ObjectKeyFromObject(nic) + uid = nic.UID + initClaimRef = *existing + needGet bool + ) + + return retry.RetryOnConflict(retry.DefaultRetry, func() error { + if needGet { + if err := c.Get(ctx, key, nic); err != nil { + return err + } + } + needGet = true + + if nic.UID != uid { + // UID has changed - different object counts as released. + return nil + } + + if actualClaimRef := v1alpha1.GetNetworkInterfaceNATClaimer(nic, ipFamily); actualClaimRef == nil || *actualClaimRef != initClaimRef { + // Claimer has already changed, counts as released. + return nil + } + + idx := slices.IndexFunc(nic.Spec.NATs, func(nicNAT v1alpha1.NetworkInterfaceNAT) bool { return nicNAT.IPFamily == ipFamily }) + nic.Spec.NATs = slices.Delete(nic.Spec.NATs, idx, idx+1) + if err := c.Patch(ctx, nic, client.MergeFromWithOptions(nic, &client.MergeFromWithOptimisticLock{})); err != nil { + return fmt.Errorf("error releasing network interface: %w", err) + } + return nil + }) +} diff --git a/onmetal-api-net/controllers/certificate/generic/certificate.go b/internal/controllers/certificate/generic/certificate.go similarity index 100% rename from onmetal-api-net/controllers/certificate/generic/certificate.go rename to internal/controllers/certificate/generic/certificate.go diff --git a/onmetal-api-net/controllers/certificate/onmetal-api-net/apinetlet.go b/internal/controllers/certificate/onmetal-api-net/apinetlet.go similarity index 94% rename from onmetal-api-net/controllers/certificate/onmetal-api-net/apinetlet.go rename to internal/controllers/certificate/onmetal-api-net/apinetlet.go index 0ad44f91..37b0df40 100644 --- a/onmetal-api-net/controllers/certificate/onmetal-api-net/apinetlet.go +++ b/internal/controllers/certificate/onmetal-api-net/apinetlet.go @@ -19,8 +19,8 @@ import ( "fmt" "strings" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/generic" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/generic" "golang.org/x/exp/slices" authv1 "k8s.io/api/authorization/v1" certificatesv1 "k8s.io/api/certificates/v1" diff --git a/onmetal-api-net/controllers/certificate/onmetal-api-net/metalnetlet.go b/internal/controllers/certificate/onmetal-api-net/metalnetlet.go similarity index 94% rename from onmetal-api-net/controllers/certificate/onmetal-api-net/metalnetlet.go rename to internal/controllers/certificate/onmetal-api-net/metalnetlet.go index 6590aa36..634157b5 100644 --- a/onmetal-api-net/controllers/certificate/onmetal-api-net/metalnetlet.go +++ b/internal/controllers/certificate/onmetal-api-net/metalnetlet.go @@ -19,8 +19,8 @@ import ( "fmt" "strings" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/generic" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/generic" "golang.org/x/exp/slices" authv1 "k8s.io/api/authorization/v1" certificatesv1 "k8s.io/api/certificates/v1" diff --git a/onmetal-api-net/controllers/certificate/onmetal-api-net/onmetalapinet.go b/internal/controllers/certificate/onmetal-api-net/onmetalapinet.go similarity index 88% rename from onmetal-api-net/controllers/certificate/onmetal-api-net/onmetalapinet.go rename to internal/controllers/certificate/onmetal-api-net/onmetalapinet.go index 5532ac69..a87a9bf2 100644 --- a/onmetal-api-net/controllers/certificate/onmetal-api-net/onmetalapinet.go +++ b/internal/controllers/certificate/onmetal-api-net/onmetalapinet.go @@ -14,6 +14,6 @@ package onmetalapinet -import "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/generic" +import "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/generic" var Recognizers []generic.CertificateSigningRequestRecognizer diff --git a/onmetal-api-net/controllers/certificateapproval_controller.go b/internal/controllers/certificateapproval_controller.go similarity index 98% rename from onmetal-api-net/controllers/certificateapproval_controller.go rename to internal/controllers/certificateapproval_controller.go index e3bee694..f3bb2753 100644 --- a/onmetal-api-net/controllers/certificateapproval_controller.go +++ b/internal/controllers/certificateapproval_controller.go @@ -18,7 +18,7 @@ import ( "context" "fmt" - "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/generic" + "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/generic" authv1 "k8s.io/api/authorization/v1" certificatesv1 "k8s.io/api/certificates/v1" corev1 "k8s.io/api/core/v1" diff --git a/onmetal-api-net/controllers/certificateapproval_test.go b/internal/controllers/certificateapproval_test.go similarity index 96% rename from onmetal-api-net/controllers/certificateapproval_test.go rename to internal/controllers/certificateapproval_test.go index 6b4a20cf..6dbd89a3 100644 --- a/onmetal-api-net/controllers/certificateapproval_test.go +++ b/internal/controllers/certificateapproval_test.go @@ -18,7 +18,7 @@ import ( "crypto/x509" "crypto/x509/pkix" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" utilcertificate "github.com/onmetal/onmetal-api/utils/certificate" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/internal/controllers/common_test.go b/internal/controllers/common_test.go new file mode 100644 index 00000000..24692a66 --- /dev/null +++ b/internal/controllers/common_test.go @@ -0,0 +1,56 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func SetupNetwork(namespace *corev1.Namespace) *v1alpha1.Network { + network := &v1alpha1.Network{} + + BeforeEach(func(ctx SpecContext) { + By("creating a network") + *network = v1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: namespace.Name, + GenerateName: "network-", + }, + } + Expect(k8sClient.Create(ctx, network)).To(Succeed()) + }) + + return network +} + +func SetupNode() *v1alpha1.Node { + return SetupNodeWithLabels(nil) +} + +func SetupNodeWithLabels(labels map[string]string) *v1alpha1.Node { + return SetupObjectStruct[*v1alpha1.Node](&k8sClient, func(node *v1alpha1.Node) { + *node = v1alpha1.Node{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "node-", + Labels: labels, + }, + } + }) +} diff --git a/internal/controllers/controllers_suite_test.go b/internal/controllers/controllers_suite_test.go new file mode 100644 index 00000000..46be1a65 --- /dev/null +++ b/internal/controllers/controllers_suite_test.go @@ -0,0 +1,179 @@ +/* +Copyright 2022 The Metal 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 controllers + +import ( + "context" + "net/netip" + "path/filepath" + "testing" + "time" + + "github.com/onmetal/controller-utils/buildutils" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + onmetalapinet "github.com/onmetal/onmetal-api-net/internal/controllers/certificate/onmetal-api-net" + "github.com/onmetal/onmetal-api-net/internal/controllers/scheduler" + "github.com/onmetal/onmetal-api-net/utils/expectations" + utilsenvtest "github.com/onmetal/onmetal-api/utils/envtest" + "github.com/onmetal/onmetal-api/utils/envtest/apiserver" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/record" + "k8s.io/utils/lru" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" + logf "sigs.k8s.io/controller-runtime/pkg/log" + //+kubebuilder:scaffold:imports +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var ( + cfg *rest.Config + k8sClient client.Client + testEnv *envtest.Environment + testEnvExt *utilsenvtest.EnvironmentExtensions + schedulerCache *scheduler.Cache +) + +const ( + pollingInterval = 50 * time.Millisecond + eventuallyTimeout = 3 * time.Second + consistentlyDuration = 1 * time.Second + apiServiceTimeout = 1 * time.Minute +) + +func TestControllers(t *testing.T) { + SetDefaultConsistentlyPollingInterval(pollingInterval) + SetDefaultEventuallyPollingInterval(pollingInterval) + SetDefaultEventuallyTimeout(eventuallyTimeout) + SetDefaultConsistentlyDuration(consistentlyDuration) + + RegisterFailHandler(Fail) + + RunSpecs(t, "Controller Suite") +} + +func PrefixV4() netip.Prefix { + return netip.MustParsePrefix("10.0.0.0/24") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(GinkgoLogr) + + var err error + + By("bootstrapping test environment") + testEnv = &envtest.Environment{} + testEnvExt = &utilsenvtest.EnvironmentExtensions{ + APIServiceDirectoryPaths: []string{filepath.Join("..", "..", "config", "apiserver", "apiservice", "bases")}, + ErrorIfAPIServicePathIsMissing: true, + } + + cfg, err = utilsenvtest.StartWithExtensions(testEnv, testEnvExt) + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + DeferCleanup(utilsenvtest.StopWithExtensions, testEnv, testEnvExt) + + Expect(v1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + SetClient(k8sClient) + + apiSrv, err := apiserver.New(cfg, apiserver.Options{ + MainPath: "github.com/onmetal/onmetal-api-net/cmd/apiserver", + BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, + ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, + Host: testEnvExt.APIServiceInstallOptions.LocalServingHost, + Port: testEnvExt.APIServiceInstallOptions.LocalServingPort, + CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir, + Args: apiserver.ProcessArgs{ + "public-prefix": []string{PrefixV4().String()}, + }, + }) + Expect(err).NotTo(HaveOccurred()) + + Expect(apiSrv.Start()).To(Succeed()) + DeferCleanup(apiSrv.Stop) + + Expect(utilsenvtest.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed()) + + k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ + Scheme: scheme.Scheme, + MetricsBindAddress: "0", + }) + Expect(err).ToNot(HaveOccurred()) + + Expect((&IPAddressGCReconciler{ + Client: k8sManager.GetClient(), + APIReader: k8sManager.GetAPIReader(), + AbsenceCache: lru.New(100), + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&NetworkIDGCReconciler{ + Client: k8sManager.GetClient(), + APIReader: k8sManager.GetAPIReader(), + AbsenceCache: lru.New(100), + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&NATGatewayReconciler{ + Client: k8sManager.GetClient(), + EventRecorder: &record.FakeRecorder{}, + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&LoadBalancerReconciler{ + Client: k8sManager.GetClient(), + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&CertificateApprovalReconciler{ + Client: k8sManager.GetClient(), + Recognizers: onmetalapinet.Recognizers, + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&NATGatewayAutoscalerReconciler{ + Client: k8sManager.GetClient(), + }).SetupWithManager(k8sManager)).To(Succeed()) + + Expect((&DaemonSetReconciler{ + Client: k8sManager.GetClient(), + Expectations: expectations.New(), + }).SetupWithManager(k8sManager)).To(Succeed()) + + schedulerCache = scheduler.NewCache(k8sManager.GetLogger(), scheduler.DefaultCacheStrategy) + Expect(k8sManager.Add(schedulerCache)).To(Succeed()) + + Expect((&SchedulerReconciler{ + Client: k8sManager.GetClient(), + EventRecorder: &record.FakeRecorder{}, + Cache: schedulerCache, + }).SetupWithManager(k8sManager)).To(Succeed()) + + mgrCtx, cancel := context.WithCancel(context.Background()) + DeferCleanup(cancel) + go func() { + defer GinkgoRecover() + Expect(k8sManager.Start(mgrCtx)).To(Succeed(), "failed to start manager") + }() +}) diff --git a/internal/controllers/daemonset_controller.go b/internal/controllers/daemonset_controller.go new file mode 100644 index 00000000..4df754ae --- /dev/null +++ b/internal/controllers/daemonset_controller.go @@ -0,0 +1,390 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "errors" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/controller-utils/metautils" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/nodeaffinity" + "github.com/onmetal/onmetal-api-net/utils/controller" + "github.com/onmetal/onmetal-api-net/utils/expectations" + utilhandler "github.com/onmetal/onmetal-api-net/utils/handler" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +type DaemonSetReconciler struct { + client.Client + Expectations *expectations.Expectations +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=daemonsets,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=daemonsets/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=instances,verbs=get;list;watch;create;update;patch;delete;deletecollection +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nodes,verbs=get;list;watch + +func (r *DaemonSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + ds := &v1alpha1.DaemonSet{} + if err := r.Get(ctx, req.NamespacedName, ds); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + return r.reconcileExists(ctx, log, ds) +} + +func (r *DaemonSetReconciler) reconcileExists( + ctx context.Context, + log logr.Logger, + ds *v1alpha1.DaemonSet, +) (ctrl.Result, error) { + if !ds.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, ds) + } + return r.reconcile(ctx, log, ds) +} + +func (r *DaemonSetReconciler) delete( + ctx context.Context, + log logr.Logger, + ds *v1alpha1.DaemonSet, +) (ctrl.Result, error) { + log.V(1).Info("Delete") + _, _ = ctx, ds + log.V(1).Info("Deleted") + return ctrl.Result{}, nil +} + +func (r *DaemonSetReconciler) instanceNeedsUpdate(ds *v1alpha1.DaemonSet, inst *v1alpha1.Instance) bool { + return !slices.Equal(inst.Spec.IPs, ds.Spec.Template.Spec.IPs) +} + +func (r *DaemonSetReconciler) updateInstance(ctx context.Context, ds *v1alpha1.DaemonSet, inst *v1alpha1.Instance) error { + base := inst.DeepCopy() + inst.Spec.IPs = ds.Spec.Template.Spec.IPs + return r.Patch(ctx, inst, client.StrategicMergeFrom(base)) +} + +func (r *DaemonSetReconciler) getDaemonInstances(ctx context.Context, ds *v1alpha1.DaemonSet) ([]*v1alpha1.Instance, error) { + sel, err := metav1.LabelSelectorAsSelector(ds.Spec.Selector) + if err != nil { + return nil, err + } + + instanceList := &v1alpha1.InstanceList{} + if err := r.List(ctx, instanceList, + client.InNamespace(ds.Namespace), + ); err != nil { + return nil, err + } + + var ( + claimMgr = controller.NewRefManager(r.Client, ds, controller.MatchLabelSelectorFunc[*v1alpha1.Instance](sel)) + insts []*v1alpha1.Instance + errs []error + ) + for i := range instanceList.Items { + inst := &instanceList.Items[i] + ok, err := claimMgr.ClaimObject(ctx, inst) + if err != nil { + errs = append(errs, err) + continue + } + if !ok { + continue + } + // TODO: Determine whether this is the right place to do this. + // Maybe an instance should only have a single IP. + // Maybe the update should be done in a later step (e.g. where we decide which instance to delete / keep). + if r.instanceNeedsUpdate(ds, inst) { + if err := r.updateInstance(ctx, ds, inst); err != nil { + errs = append(errs, err) + continue + } + } + + insts = append(insts, inst) + } + return insts, errors.Join(errs...) +} + +func (r *DaemonSetReconciler) getNodesToDaemonInstances(ctx context.Context, log logr.Logger, ds *v1alpha1.DaemonSet) (map[string][]*v1alpha1.Instance, error) { + claimedInsts, err := r.getDaemonInstances(ctx, ds) + if err != nil { + return nil, err + } + + nodeToDaemonInsts := make(map[string][]*v1alpha1.Instance) + for _, inst := range claimedInsts { + nodeName, err := GetTargetNodeName(inst) + if err != nil { + log.Info("Failed to get target node name of Instance in DaemonSet", + "Instance", klog.KObj(inst), + ) + continue + } + + nodeToDaemonInsts[nodeName] = append(nodeToDaemonInsts[nodeName], inst) + } + + return nodeToDaemonInsts, nil +} + +func (r *DaemonSetReconciler) nodeShouldRunDaemonInstance( + node *v1alpha1.Node, + ds *v1alpha1.DaemonSet, +) bool { + // If the daemon set specifies a node name, and it does not match with our node name bail out immediately. + if nodeRef := ds.Spec.Template.Spec.NodeRef; nodeRef != nil && nodeRef.Name != node.Name { + return false + } + + inst := &v1alpha1.Instance{ + ObjectMeta: ds.Spec.Template.ObjectMeta, + Spec: ds.Spec.Template.Spec, + } + inst.Namespace = ds.Namespace + inst.Spec.NodeRef = &corev1.LocalObjectReference{Name: node.Name} + + fitsNodeAffinity, _ := nodeaffinity.GetRequiredNodeAffinity(inst).Match(node) + return fitsNodeAffinity +} + +func (r *DaemonSetReconciler) instancesShouldBeOnNode( + log logr.Logger, + node *v1alpha1.Node, + nodeToDaemonInsts map[string][]*v1alpha1.Instance, + ds *v1alpha1.DaemonSet, + hash string, +) (nodesNeedingDaemonInsts []string, instsToDelete []string) { + _, _ = log, hash + shouldRun := r.nodeShouldRunDaemonInstance(node, ds) + _, exists := nodeToDaemonInsts[node.Name] + + switch { + case shouldRun && !exists: + // If a daemon instance is supposed to be running on a node but isn't, create one. + nodesNeedingDaemonInsts = append(nodesNeedingDaemonInsts, node.Name) + // TODO: Add cases handling deletion of instances that should not be on a node anymore. + } + + return nodesNeedingDaemonInsts, instsToDelete +} + +func (r *DaemonSetReconciler) getUnscheduledInstancesWithoutNode( + nodes []v1alpha1.Node, + nodeToDaemonInsts map[string][]*v1alpha1.Instance, +) []string { + var ( + res []string + nodeNames = utilslices.ToSetFunc(nodes, func(n v1alpha1.Node) string { return n.Name }) + ) + + for nodeName, insts := range nodeToDaemonInsts { + if nodeNames.Has(nodeName) { + continue + } + + for _, inst := range insts { + if inst.Spec.NodeRef == nil { + res = append(res, inst.Name) + } + } + } + return res +} + +func (r *DaemonSetReconciler) manage( + ctx context.Context, + log logr.Logger, + ds *v1alpha1.DaemonSet, + nodes []v1alpha1.Node, + hash string, +) error { + nodeToDaemonInsts, err := r.getNodesToDaemonInstances(ctx, log, ds) + if err != nil { + return fmt.Errorf("error getting node to daemon instance mapping: %w", err) + } + + var ( + nodesNeedingDaemonInsts []string + instsToDelete []string + ) + for i := range nodes { + node := &nodes[i] + nodeDaemonInsts, nodeInstsToDelete := r.instancesShouldBeOnNode(log, node, nodeToDaemonInsts, ds, hash) + + nodesNeedingDaemonInsts = append(nodesNeedingDaemonInsts, nodeDaemonInsts...) + instsToDelete = append(instsToDelete, nodeInstsToDelete...) + } + + instsToDelete = append(instsToDelete, r.getUnscheduledInstancesWithoutNode(nodes, nodeToDaemonInsts)...) + + if err := r.syncNodes(ctx, ds, instsToDelete, nodesNeedingDaemonInsts, hash); err != nil { + return err + } + + return nil +} + +func (r *DaemonSetReconciler) createInstance( + ctx context.Context, + ds *v1alpha1.DaemonSet, + nodeName string, + instName string, + hash string, +) (*v1alpha1.Instance, error) { + templ := ds.Spec.Template.DeepCopy() + inst := &v1alpha1.Instance{ + ObjectMeta: templ.ObjectMeta, + Spec: templ.Spec, + } + inst.Namespace = ds.Namespace + inst.Name = instName + metautils.SetLabel(inst, v1alpha1.ControllerRevisionHashLabel, hash) + inst.Spec.Affinity = ReplaceDaemonSetInstanceNodeNameNodeAffinity(inst.Spec.Affinity, nodeName) + if err := ctrl.SetControllerReference(ds, inst, r.Scheme()); err != nil { + return nil, err + } + + if err := r.Create(ctx, inst); err != nil { + return nil, err + } + return inst, nil +} + +func (r *DaemonSetReconciler) syncNodes( + ctx context.Context, + ds *v1alpha1.DaemonSet, + instsToDelete []string, + nodesNeedingDaemonInsts []string, + hash string, +) error { + var ( + ctrlKey = client.ObjectKeyFromObject(ds) + createNames = expectations.GenerateCreateNames(ds.Name, len(nodesNeedingDaemonInsts)) + ) + r.Expectations.ExpectCreationsAndDeletions(ctrlKey, + expectations.ObjectKeysFromNames(ds.Namespace, createNames), + expectations.ObjectKeysFromNames(ds.Namespace, instsToDelete), + ) + + var errs []error + + for i, createName := range createNames { + nodeName := nodesNeedingDaemonInsts[i] + if _, err := r.createInstance(ctx, ds, nodeName, createName, hash); err != nil { + r.Expectations.CreationObserved(ctrlKey, client.ObjectKey{Namespace: ds.Namespace, Name: createName}) + errs = append(errs, err) + } + } + + for _, deleteName := range instsToDelete { + inst := &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ds.Namespace, + Name: deleteName, + }, + } + instKey := client.ObjectKeyFromObject(inst) + if err := r.Delete(ctx, inst); err != nil { + r.Expectations.DeletionObserved(ctrlKey, instKey) + if !apierrors.IsNotFound(err) { + errs = append(errs, err) + } + } + } + + return errors.Join(errs...) +} + +func (r *DaemonSetReconciler) reconcile( + ctx context.Context, + log logr.Logger, + ds *v1alpha1.DaemonSet, +) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + nodeList := &v1alpha1.NodeList{} + if err := r.List(ctx, nodeList); err != nil { + return ctrl.Result{}, fmt.Errorf("error listing nodes: %w", err) + } + + hash := ComputeHash(&ds.Spec.Template, ds.Status.CollisionCount) + + if r.Expectations.Satisfied(client.ObjectKeyFromObject(ds)) { + log.V(1).Info("Managing daemon set") + if err := r.manage(ctx, log, ds, nodeList.Items, hash); err != nil { + return ctrl.Result{}, fmt.Errorf("error managing daemon set: %w", err) + } + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *DaemonSetReconciler) enqueueByNode() handler.EventHandler { + enqueueAllDaemonSets := func(ctx context.Context, queue workqueue.RateLimitingInterface) { + log := ctrl.LoggerFrom(ctx) + dsList := &v1alpha1.DaemonSetList{} + + if err := r.List(ctx, dsList); err != nil { + log.Error(err, "Error listing daemon sets") + return + } + + for _, ds := range dsList.Items { + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&ds)}) + } + } + + return handler.Funcs{ + CreateFunc: func(ctx context.Context, evt event.CreateEvent, queue workqueue.RateLimitingInterface) { + enqueueAllDaemonSets(ctx, queue) + }, + DeleteFunc: func(ctx context.Context, evt event.DeleteEvent, queue workqueue.RateLimitingInterface) { + enqueueAllDaemonSets(ctx, queue) + }, + } +} + +func (r *DaemonSetReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&v1alpha1.DaemonSet{}). + Owns(&v1alpha1.Instance{}). + Watches( + &v1alpha1.Instance{}, + utilhandler.ObserveExpectationsForController(r.Scheme(), r.RESTMapper(), &v1alpha1.DaemonSet{}, r.Expectations), + ). + Watches( + &v1alpha1.Node{}, + r.enqueueByNode(), + ). + Complete(r) +} diff --git a/internal/controllers/daemonset_controller_test.go b/internal/controllers/daemonset_controller_test.go new file mode 100644 index 00000000..84ffd1e6 --- /dev/null +++ b/internal/controllers/daemonset_controller_test.go @@ -0,0 +1,100 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("DaemonSetController", func() { + ns := SetupNamespace(&k8sClient) + network := SetupNetwork(ns) + node1, node2 := SetupNode(), SetupNode() + + It("should correctly manage the daemon set instances", func(ctx SpecContext) { + By("creating a daemon set") + ds := &v1alpha1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "ds-", + }, + Spec: v1alpha1.DaemonSetSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + Template: v1alpha1.InstanceTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"foo": "bar"}, + }, + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPs: []net.IP{net.MustParseIP("10.0.0.1")}, + }, + }, + }, + } + Expect(k8sClient.Create(ctx, ds)).To(Succeed()) + + By("waiting for instances to be present with affinity for each node") + nodeAffinityFor := func(nodeName string) *v1alpha1.Affinity { + return &v1alpha1.Affinity{ + NodeAffinity: &v1alpha1.NodeAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: &v1alpha1.NodeSelector{ + NodeSelectorTerms: []v1alpha1.NodeSelectorTerm{ + { + MatchFields: []v1alpha1.NodeSelectorRequirement{ + { + Key: "metadata.name", + Operator: v1alpha1.NodeSelectorOpIn, + Values: []string{nodeName}, + }, + }, + }, + }, + }, + }, + } + } + Eventually(ObjectList(&v1alpha1.InstanceList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", SatisfyAll( + HaveEach(HaveField("Spec.IPs", []net.IP{net.MustParseIP("10.0.0.1")})), + ConsistOf( + HaveField("Spec.Affinity", nodeAffinityFor(node1.Name)), + HaveField("Spec.Affinity", nodeAffinityFor(node2.Name)), + )), + )) + + By("updating the daemon set template IPs") + Eventually(Update(ds, func() { + ds.Spec.Template.Spec.IPs = []net.IP{net.MustParseIP("192.168.178.1")} + })).Should(Succeed()) + + By("waiting until the instance IPs are updated") + Eventually(ObjectList(&v1alpha1.InstanceList{}, + client.InNamespace(ns.Name), + )).Should(HaveField("Items", HaveEach(HaveField("Spec.IPs", []net.IP{net.MustParseIP("192.168.178.1")})))) + }) +}) diff --git a/internal/controllers/helper.go b/internal/controllers/helper.go new file mode 100644 index 00000000..172e2ac5 --- /dev/null +++ b/internal/controllers/helper.go @@ -0,0 +1,23 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + fieldOwner = client.FieldOwner("apinet.api.onmetal.de/controller-manager") +) diff --git a/internal/controllers/ipaddressgc_controller.go b/internal/controllers/ipaddressgc_controller.go new file mode 100644 index 00000000..48033155 --- /dev/null +++ b/internal/controllers/ipaddressgc_controller.go @@ -0,0 +1,162 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/util/workqueue" + "k8s.io/utils/lru" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +type IPAddressGCReconciler struct { + client.Client + APIReader client.Reader + + AbsenceCache *lru.Cache +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=ipaddress,verbs=get;list;watch;delete +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=ip,verbs=get;list;watch + +func (r *IPAddressGCReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + addr := &v1alpha1.IPAddress{} + if err := r.Get(ctx, req.NamespacedName, addr); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + if !addr.DeletionTimestamp.IsZero() { + // Don't try to GC addresses that are already deleting. + return ctrl.Result{}, nil + } + + log.V(1).Info("Checking whether IP address claimer exists") + ok, err := r.ipAddressClaimerExists(ctx, addr) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error checking whether IP address claimer exists: %w", err) + } + if ok { + log.V(1).Info("IP address claimer is still present") + return ctrl.Result{}, nil + } + + log.V(1).Info("IP address claimer does not exist, releasing IP address") + if err := r.Delete(ctx, addr); client.IgnoreNotFound(err) != nil { + return ctrl.Result{}, fmt.Errorf("error deleting IP address: %w", err) + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *IPAddressGCReconciler) ipAddressClaimerExists(ctx context.Context, addr *v1alpha1.IPAddress) (bool, error) { + claimRef := addr.Spec.ClaimRef + if _, ok := r.AbsenceCache.Get(claimRef.UID); ok { + return false, nil + } + + gvr := schema.GroupVersionResource{ + Resource: claimRef.Resource, + Group: claimRef.Group, + } + resList, err := r.RESTMapper().KindsFor(gvr) + if err != nil { + return false, fmt.Errorf("error getting kinds for %s: %w", gvr.GroupResource(), err) + } + if len(resList) == 0 { + return false, fmt.Errorf("no kind for %s", gvr.GroupResource()) + } + + gvk := resList[0] + + mapping, err := r.RESTMapper().RESTMapping(gvk.GroupKind(), gvk.Version) + if err != nil { + return false, fmt.Errorf("error getting REST mapping for %s: %w", gvk, err) + } + + claimer := &metav1.PartialObjectMetadata{ + TypeMeta: metav1.TypeMeta{ + APIVersion: gvk.GroupVersion().String(), + Kind: gvk.Kind, + }, + } + claimerKey := client.ObjectKey{Name: claimRef.Name} + if mapping.Scope.Name() == meta.RESTScopeNameNamespace { + claimerKey.Namespace = addr.Namespace + } + + if err := r.APIReader.Get(ctx, claimerKey, claimer); err != nil { + if !apierrors.IsNotFound(err) { + return false, fmt.Errorf("error getting claiming %s %s: %w", gvk, claimRef.Name, err) + } + + r.AbsenceCache.Add(claimRef.UID, nil) + return false, nil + } + return true, nil +} + +func (r *IPAddressGCReconciler) enqueueByClaimer() handler.EventHandler { + mapAndEnqueue := func(ctx context.Context, claimer client.Object, queue workqueue.RateLimitingInterface) { + log := ctrl.LoggerFrom(ctx) + + addrList := &v1alpha1.IPAddressList{} + if err := r.List(ctx, addrList, + client.InNamespace(claimer.GetNamespace()), + ); err != nil { + log.Error(err, "Error listing IP addresses") + return + } + + for _, addr := range addrList.Items { + if v1alpha1.IsIPAddressClaimedBy(&addr, claimer) { + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&addr)}) + } + } + } + + return &handler.Funcs{ + DeleteFunc: func(ctx context.Context, event event.DeleteEvent, queue workqueue.RateLimitingInterface) { + mapAndEnqueue(ctx, event.Object, queue) + }, + GenericFunc: func(ctx context.Context, event event.GenericEvent, queue workqueue.RateLimitingInterface) { + if !event.Object.GetDeletionTimestamp().IsZero() { + mapAndEnqueue(ctx, event.Object, queue) + } + }, + } +} + +func (r *IPAddressGCReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + Named("ipaddressgc"). + For(&v1alpha1.IPAddress{}). + Watches( + &v1alpha1.IP{}, + r.enqueueByClaimer(), + ). + Complete(r) +} diff --git a/internal/controllers/ipaddressgc_controller_test.go b/internal/controllers/ipaddressgc_controller_test.go new file mode 100644 index 00000000..ea7a49ab --- /dev/null +++ b/internal/controllers/ipaddressgc_controller_test.go @@ -0,0 +1,59 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/google/uuid" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("IPAddressGarbageCollectorController", func() { + It("should release a IP address with a non-existent claimer", func(ctx SpecContext) { + By("creating a IP address") + var addr *v1alpha1.IPAddress + // We have to create the IP address in a loop since we can *not* know the free IP addresses. + // This is 'ugly', however, it's the best we can do with the current implementation. + for ip := PrefixV4().Masked().Addr(); PrefixV4().Contains(ip); ip = ip.Next() { + addr = &v1alpha1.IPAddress{ + ObjectMeta: metav1.ObjectMeta{ + Name: ip.String(), + }, + Spec: v1alpha1.IPAddressSpec{ + ClaimRef: v1alpha1.IPAddressClaimRef{ + Group: v1alpha1.GroupName, + Resource: "natgateways", + UID: types.UID(uuid.NewString()), + Name: "should-not-exist", + }, + }, + } + err := k8sClient.Create(ctx, addr) + if err == nil { + break + } + Expect(err).To(Satisfy(apierrors.IsAlreadyExists)) + } + Expect(addr).NotTo(BeNil(), "no free IP address could be found / created") + + By("waiting for the IP address to be deleted") + Eventually(Get(addr)).Should(Satisfy(apierrors.IsNotFound)) + }) +}) diff --git a/internal/controllers/loadbalancer_controller.go b/internal/controllers/loadbalancer_controller.go new file mode 100644 index 00000000..8e84fdd1 --- /dev/null +++ b/internal/controllers/loadbalancer_controller.go @@ -0,0 +1,105 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type LoadBalancerReconciler struct { + client.Client +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancers,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancers/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancers,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=daemonsets,verbs=get;list;watch;create;update;patch + +func (r *LoadBalancerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + loadBalancer := &v1alpha1.LoadBalancer{} + if err := r.Get(ctx, req.NamespacedName, loadBalancer); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + return r.reconcileExists(ctx, log, loadBalancer) +} + +func (r *LoadBalancerReconciler) reconcileExists(ctx context.Context, log logr.Logger, loadBalancer *v1alpha1.LoadBalancer) (ctrl.Result, error) { + if !loadBalancer.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, loadBalancer) + } + return r.reconcile(ctx, log, loadBalancer) +} + +func (r *LoadBalancerReconciler) delete(ctx context.Context, log logr.Logger, loadBalancer *v1alpha1.LoadBalancer) (ctrl.Result, error) { + _, _ = ctx, loadBalancer + log.V(1).Info("Delete") + log.V(1).Info("Deleted") + return ctrl.Result{}, nil +} + +func (r *LoadBalancerReconciler) reconcile(ctx context.Context, log logr.Logger, loadBalancer *v1alpha1.LoadBalancer) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + if err := r.applyDaemonSetForLoadBalancer(ctx, loadBalancer); err != nil { + return ctrl.Result{}, fmt.Errorf("error applying daemon set: %w", err) + } + log.V(1).Info("Applied daemon set") + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *LoadBalancerReconciler) applyDaemonSetForLoadBalancer(ctx context.Context, loadBalancer *v1alpha1.LoadBalancer) error { + daemonSet := &v1alpha1.DaemonSet{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "DaemonSet", + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: loadBalancer.Namespace, + Name: v1alpha1.LoadBalancerDaemonSetName(loadBalancer.Name), + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(loadBalancer, v1alpha1.SchemeGroupVersion.WithKind("LoadBalancer")), + }, + }, + Spec: v1alpha1.DaemonSetSpec{ + Selector: loadBalancer.Spec.Selector, + Template: loadBalancer.Spec.Template, + }, + } + daemonSet.Spec.Template.Spec.Type = v1alpha1.InstanceTypeLoadBalancer + daemonSet.Spec.Template.Spec.LoadBalancerType = loadBalancer.Spec.Type + daemonSet.Spec.Template.Spec.IPs = v1alpha1.GetLoadBalancerIPs(loadBalancer) + daemonSet.Spec.Template.Spec.NetworkRef = loadBalancer.Spec.NetworkRef + daemonSet.Spec.Template.Spec.LoadBalancerPorts = loadBalancer.Spec.Ports + err := r.Patch(ctx, daemonSet, client.Apply, fieldOwner, client.ForceOwnership) + return err +} + +func (r *LoadBalancerReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&v1alpha1.LoadBalancer{}). + Owns(&v1alpha1.DaemonSet{}). + Complete(r) +} diff --git a/internal/controllers/loadbalancer_controller_test.go b/internal/controllers/loadbalancer_controller_test.go new file mode 100644 index 00000000..eee896c0 --- /dev/null +++ b/internal/controllers/loadbalancer_controller_test.go @@ -0,0 +1,76 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("LoadBalancerController", func() { + ns := SetupNamespace(&k8sClient) + network := SetupNetwork(ns) + + It("should reconcile the load balancer", func(ctx SpecContext) { + By("creating a load balancer") + loadBalancer := &v1alpha1.LoadBalancer{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "load-balancer-", + }, + Spec: v1alpha1.LoadBalancerSpec{ + Type: v1alpha1.LoadBalancerTypePublic, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPs: []v1alpha1.LoadBalancerIP{ + { + Name: "ip-1", + IPFamily: corev1.IPv4Protocol, + }, + }, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + } + Expect(k8sClient.Create(ctx, loadBalancer)).To(Succeed()) + ips := v1alpha1.GetLoadBalancerIPs(loadBalancer) + + By("waiting for the load balancer to create a daemon set") + daemonSet := &v1alpha1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: v1alpha1.LoadBalancerDaemonSetName(loadBalancer.Name), + }, + } + Eventually(Object(daemonSet)).Should(HaveField("Spec", v1alpha1.DaemonSetSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + Template: v1alpha1.InstanceTemplate{ + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPs: ips, + }, + }, + })) + }) +}) diff --git a/internal/controllers/natgateway_controller.go b/internal/controllers/natgateway_controller.go new file mode 100644 index 00000000..f706a1c9 --- /dev/null +++ b/internal/controllers/natgateway_controller.go @@ -0,0 +1,460 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "errors" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + apinetclient "github.com/onmetal/onmetal-api-net/internal/client" + "github.com/onmetal/onmetal-api-net/internal/natgateway" + "github.com/onmetal/onmetal-api/utils/maps" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + "golang.org/x/exp/slices" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +type NATGatewayReconciler struct { + client.Client + record.EventRecorder +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgateway,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgateway/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nattable,verbs=get;list;watch;create;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkinterfaces,verbs=get;list;watch;patch;update + +func (r *NATGatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + natGateway := &v1alpha1.NATGateway{} + if err := r.Get(ctx, req.NamespacedName, natGateway); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, err + } + + natTable := &v1alpha1.NATTable{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: req.Namespace, + Name: req.Name, + }, + } + if err := r.Delete(ctx, natTable); client.IgnoreNotFound(err) != nil { + return ctrl.Result{}, fmt.Errorf("error deleting NAT table: %w", err) + } + return ctrl.Result{}, nil + } + return r.reconcileExists(ctx, log, natGateway) +} + +func (r *NATGatewayReconciler) reconcileExists(ctx context.Context, log logr.Logger, natGateway *v1alpha1.NATGateway) (ctrl.Result, error) { + if !natGateway.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, natGateway) + } + return r.reconcile(ctx, log, natGateway) +} + +func (r *NATGatewayReconciler) delete(ctx context.Context, log logr.Logger, natGateway *v1alpha1.NATGateway) (ctrl.Result, error) { + log.V(1).Info("Delete") + log.V(1).Info("Deleted") + return ctrl.Result{}, nil +} + +func (r *NATGatewayReconciler) updateNATGatewayUsedRequests( + ctx context.Context, + natGateway *v1alpha1.NATGateway, + usedNATIPs int64, + requests int64, +) error { + base := natGateway.DeepCopy() + natGateway.Status.UsedNATIPs = usedNATIPs + natGateway.Status.RequestedNATIPs = requests + if err := r.Status().Patch(ctx, natGateway, client.MergeFrom(base)); err != nil { + return fmt.Errorf("error patching nat gateway status: %w", err) + } + return nil +} + +// natIPAllocation bundles a NAT IP with a target. +type natIPAllocation struct { + // IP is the NATed IP. + ip net.IP + // NATIPSection is the target of the ip. + v1alpha1.NATIPSection +} + +func (r *NATGatewayReconciler) getExistingAllocations(ctx context.Context, natGateway *v1alpha1.NATGateway, ips []net.IP) (map[types.UID]natIPAllocation, error) { + routing := &v1alpha1.NATTable{} + if err := r.Get(ctx, client.ObjectKeyFromObject(natGateway), routing); err != nil { + if !apierrors.IsNotFound(err) { + return nil, fmt.Errorf("error getting NAT gateway routing: %w", err) + } + + return nil, nil + } + + var ( + mgr = natgateway.NewAllocationManager(natGateway.Spec.PortsPerNetworkInterface, ips) + allocByID = make(map[types.UID]natIPAllocation) + ) + + for _, ip := range routing.IPs { + if !mgr.HasIP(ip.IP) { + // IP has been removed - short circuit iteration and continue. + continue + } + + for _, tgt := range ip.Sections { + ref := tgt.TargetRef + if ref == nil { + // TODO: When IPs are finally unique, we don't need the TargetRef anymore. + continue + } + if mgr.Use(ip.IP, tgt.Port, tgt.EndPort) { + allocByID[ref.UID] = natIPAllocation{ip.IP, tgt} + } + } + } + return allocByID, nil +} + +func (r *NATGatewayReconciler) natGatewayNetworkInterfaceSelector(natGateway *v1alpha1.NATGateway) func(*v1alpha1.NetworkInterface) bool { + return func(nic *v1alpha1.NetworkInterface) bool { + var found bool + for _, ip := range nic.Spec.IPs { + if ip.Family() == natGateway.Spec.IPFamily { + found = true + break + } + } + if !found { + // Network interface does not support the NAT ip family. + return false + } + + for _, publicIP := range nic.Spec.PublicIPs { + if publicIP.IPFamily == natGateway.Spec.IPFamily { + // Network interface already has a public IP. + return false + } + } + + return true + } +} + +func (r *NATGatewayReconciler) manageNATTable( + ctx context.Context, + natGateway *v1alpha1.NATGateway, + ips []net.IP, + existingAllocByNicID map[types.UID]natIPAllocation, +) (used, requests int64, err error) { + nicList := &v1alpha1.NetworkInterfaceList{} + if err := r.List(ctx, nicList, + client.InNamespace(natGateway.Namespace), + ); err != nil { + return 0, 0, fmt.Errorf("error listing network interfaces: %w", err) + } + + var ( + mgr = natgateway.NewAllocationManager(natGateway.Spec.PortsPerNetworkInterface, ips) + sel = r.natGatewayNetworkInterfaceSelector(natGateway) + ipToAllocation = make(map[net.IP]map[types.UID]v1alpha1.NATIPSection) + addAlloc = func(ip net.IP, target v1alpha1.NATIPSection) { + ipToAllocation[ip] = maps.Append(ipToAllocation[ip], target.TargetRef.UID, target) + } + getNicIP = func(nic *v1alpha1.NetworkInterface) net.IP { + for _, ip := range nic.Spec.IPs { + if ip.Family() == natGateway.Spec.IPFamily { + return ip + } + } + return net.IP{} + } + processClaimed []int + processFree []int + errs []error + ) + for i, nic := range nicList.Items { + claimer := v1alpha1.GetNetworkInterfaceNATClaimer(&nic, natGateway.Spec.IPFamily) + if claimer != nil { + if claimer.UID != natGateway.UID { + // Claimed by someone else, ignore. + continue + } + + if sel(&nic) { + // We claim it and match it. + requests++ + existing, ok := existingAllocByNicID[nic.UID] + if ok { + // Re-use existing allocation. + mgr.Use(existing.ip, existing.Port, existing.EndPort) + addAlloc(existing.ip, existing.NATIPSection) + continue + } + + // We claim it and match it, however there's no allocation - process to see if we can allocate it. + processClaimed = append(processClaimed, i) + continue + } + + // We don't match it - release it if possible. + if err := apinetclient.ReleaseNetworkInterfaceNAT(ctx, r.Client, &nic, natGateway.Spec.IPFamily); client.IgnoreNotFound(err) != nil { + errs = append(errs, err) + } + continue + } + + // It's not being claimed at the moment. + + if !sel(&nic) || !nic.DeletionTimestamp.IsZero() { + // We don't want to claim it - skip it. + continue + } + + // Mark to be processed. + requests++ + processFree = append(processFree, i) + } + + var full bool + for _, i := range processClaimed { + nic := nicList.Items[i] + + if !full { + ip, port, endPort, ok := mgr.UseNextFree() + if ok { + // Already claimed - just add the allocation and proceed. + addAlloc(ip, v1alpha1.NATIPSection{ + IP: getNicIP(&nic), + Port: port, + EndPort: endPort, + TargetRef: &v1alpha1.NATTableIPTargetRef{ + UID: nic.UID, + Name: nic.Name, + NodeRef: nic.Spec.NodeRef, + }, + }) + continue + } + + // Mark as full + full = true + } + + if err := apinetclient.ReleaseNetworkInterfaceNAT(ctx, r.Client, &nic, natGateway.Spec.IPFamily); client.IgnoreNotFound(err) != nil { + errs = append(errs, err) + continue + } + } + + if !full { + // Initialize IP and ports here to re-use in case we cannot claim a network interface. + var ( + ip net.IP + port, endPort int32 + shouldUseNextFree = true + claimRef = v1alpha1.NetworkInterfaceNATClaimRef{ + Name: natGateway.Name, + UID: natGateway.UID, + } + ) + for _, i := range processFree { + nic := nicList.Items[i] + + if shouldUseNextFree { + var ok bool + ip, port, endPort, ok = mgr.UseNextFree() + if !ok { + break + } + + shouldUseNextFree = false + } + + if err := apinetclient.ClaimNetworkInterfaceNAT(ctx, r.Client, &nic, natGateway.Spec.IPFamily, claimRef); err != nil { + if !apierrors.IsNotFound(err) { + // We only care about non-not-found errors - if it doesn't exist, simply don't allocate. + errs = append(errs, err) + } + continue + } + + addAlloc(ip, v1alpha1.NATIPSection{ + IP: getNicIP(&nic), + Port: port, + EndPort: endPort, + TargetRef: &v1alpha1.NATTableIPTargetRef{ + UID: nic.UID, + Name: nic.Name, + NodeRef: nic.Spec.NodeRef, + }, + }) + shouldUseNextFree = true // set shouldUseNextFree to true in order to issue using next IP again. + } + } + + if err := r.applyNATTable(ctx, natGateway, ipToAllocation); err != nil { + errs = append(errs, err) + } + + return mgr.Used(), requests, errors.Join(errs...) +} + +func (r *NATGatewayReconciler) applyNATTable( + ctx context.Context, + natGateway *v1alpha1.NATGateway, + natTableData map[net.IP]map[types.UID]v1alpha1.NATIPSection, +) error { + natTable := &v1alpha1.NATTable{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "NATTable", + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: natGateway.Namespace, + Name: natGateway.Name, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(natGateway, v1alpha1.SchemeGroupVersion.WithKind("NATGateway")), + }, + }, + } + for ip, allocs := range natTableData { + natIP := v1alpha1.NATIP{IP: ip} + for _, alloc := range allocs { + natIP.Sections = append(natIP.Sections, alloc) + } + slices.SortFunc(natIP.Sections, func(a, b v1alpha1.NATIPSection) bool { + return a.Port < b.Port + }) + natTable.IPs = append(natTable.IPs, natIP) + } + slices.SortFunc(natTable.IPs, func(a, b v1alpha1.NATIP) bool { + return a.IP.Compare(b.IP.Addr) < 0 + }) + + if err := r.Patch(ctx, natTable, client.Apply, fieldOwner, client.ForceOwnership); err != nil { + return fmt.Errorf("error applying NAT table: %w", err) + } + return nil +} + +func (r *NATGatewayReconciler) reconcile(ctx context.Context, log logr.Logger, natGateway *v1alpha1.NATGateway) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + ips := v1alpha1.GetNATGatewayIPs(natGateway) + + existingAllocs, err := r.getExistingAllocations(ctx, natGateway, ips) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error getting existing allocations: %w", err) + } + + log.V(1).Info("Managing NAT Table") + used, requests, err := r.manageNATTable(ctx, natGateway, ips, existingAllocs) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error managing NAT IPs: %w", err) + } + + if used != natGateway.Status.UsedNATIPs || requests != natGateway.Status.RequestedNATIPs { + log.V(1).Info("Updating NAT Gateway status used NAT IPs", "Used", used, "Requests", requests) + if err := r.updateNATGatewayUsedRequests(ctx, natGateway, used, requests); err != nil { + return ctrl.Result{}, fmt.Errorf("error updating NAT gateway used / requested NAT IPs: %w", err) + } + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *NATGatewayReconciler) enqueueByNetworkInterfaceNAT() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + nic := obj.(*v1alpha1.NetworkInterface) + + var reqs []ctrl.Request + for _, nicNAT := range nic.Spec.NATs { + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKey{ + Namespace: nic.Namespace, + Name: nicNAT.ClaimRef.Name, + }}) + } + return reqs + }) +} + +func (r *NATGatewayReconciler) enqueueByNATGatewayNetworkInterfaceSelection() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + nic := obj.(*v1alpha1.NetworkInterface) + log := ctrl.LoggerFrom(ctx) + + freeNicNATIPFamilies := utilslices.ToSetFunc(nic.Spec.IPs, net.IP.Family) + for _, publicIP := range nic.Spec.PublicIPs { + freeNicNATIPFamilies.Delete(publicIP.IPFamily) + if freeNicNATIPFamilies.Len() == 0 { + return nil + } + } + for _, nicNAT := range nic.Spec.NATs { + freeNicNATIPFamilies.Delete(nicNAT.IPFamily) + if freeNicNATIPFamilies.Len() == 0 { + return nil + } + } + + natGatewayList := &v1alpha1.NATGatewayList{} + if err := r.List(ctx, natGatewayList, + client.InNamespace(nic.Namespace), + ); err != nil { + log.Error(err, "Error listing NAT gateways") + return nil + } + + var reqs []ctrl.Request + for _, natGateway := range natGatewayList.Items { + if !natGateway.DeletionTimestamp.IsZero() { + continue + } + + if freeNicNATIPFamilies.Has(natGateway.Spec.IPFamily) { + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&natGateway)}) + } + } + return reqs + }) +} + +func (r *NATGatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&v1alpha1.NATGateway{}). + Owns(&v1alpha1.NATTable{}). + Watches( + &v1alpha1.NetworkInterface{}, + r.enqueueByNetworkInterfaceNAT(), + ). + Watches( + &v1alpha1.NetworkInterface{}, + r.enqueueByNATGatewayNetworkInterfaceSelection(), + ). + Complete(r) +} diff --git a/internal/controllers/natgateway_controller_test.go b/internal/controllers/natgateway_controller_test.go new file mode 100644 index 00000000..60dbc80d --- /dev/null +++ b/internal/controllers/natgateway_controller_test.go @@ -0,0 +1,90 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("NATGatewayController", func() { + ns := SetupNamespace(&k8sClient) + network := SetupNetwork(ns) + + It("should correctly reconcile the NAT gateway", func(ctx SpecContext) { + By("creating a NAT gateway") + natGateway := &v1alpha1.NATGateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nat-gateway-", + }, + Spec: v1alpha1.NATGatewaySpec{ + IPFamily: corev1.IPv4Protocol, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + PortsPerNetworkInterface: 64, + IPs: []v1alpha1.NATGatewayIP{ + {Name: "ip-1"}, + }, + }, + } + Expect(k8sClient.Create(ctx, natGateway)).To(Succeed()) + natGatewayIP := natGateway.Spec.IPs[0].IP + + By("creating a network interface as potential target") + nic := &v1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nic-", + }, + Spec: v1alpha1.NetworkInterfaceSpec{ + NodeRef: corev1.LocalObjectReference{Name: "my-node"}, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPs: []net.IP{net.MustParseIP("10.0.0.1")}, + }, + } + Expect(k8sClient.Create(ctx, nic)).To(Succeed()) + + By("waiting for the NAT table to be updated") + natTable := &v1alpha1.NATTable{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: natGateway.Name, + }, + } + Eventually(Object(natTable)).Should(HaveField("IPs", ConsistOf( + v1alpha1.NATIP{ + IP: natGatewayIP, + Sections: []v1alpha1.NATIPSection{ + { + IP: net.MustParseIP("10.0.0.1"), + Port: 1024, + EndPort: 1087, + TargetRef: &v1alpha1.NATTableIPTargetRef{ + UID: nic.UID, + Name: nic.Name, + NodeRef: nic.Spec.NodeRef, + }, + }, + }, + }, + ))) + }) +}) diff --git a/internal/controllers/natgatewayautoscaler_controller.go b/internal/controllers/natgatewayautoscaler_controller.go new file mode 100644 index 00000000..62a21dc7 --- /dev/null +++ b/internal/controllers/natgatewayautoscaler_controller.go @@ -0,0 +1,191 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/natgateway" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + apierrors "k8s.io/apimachinery/pkg/api/errors" + utilrand "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/apimachinery/pkg/util/sets" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +const ( + noOfNATIPGenerateNameChars = 10 +) + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgatewayautoscalers,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgatewayautoscalers/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgateways,verbs=get;list;watch;update;patch + +type NATGatewayAutoscalerReconciler struct { + client.Client +} + +func (r *NATGatewayAutoscalerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + natGatewayAutoscaler := &v1alpha1.NATGatewayAutoscaler{} + if err := r.Get(ctx, req.NamespacedName, natGatewayAutoscaler); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + return r.reconcileExists(ctx, log, natGatewayAutoscaler) +} + +func (r *NATGatewayAutoscalerReconciler) reconcileExists(ctx context.Context, log logr.Logger, natGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler) (ctrl.Result, error) { + natGatewayName := natGatewayAutoscaler.Spec.NATGatewayRef.Name + log = log.WithValues("NATGatewayName", natGatewayName) + + if !natGatewayAutoscaler.DeletionTimestamp.IsZero() { + return ctrl.Result{}, nil + } + return r.reconcile(ctx, log, natGatewayAutoscaler) +} + +func (r *NATGatewayAutoscalerReconciler) reconcile(ctx context.Context, log logr.Logger, natGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + log.V(1).Info("Getting scale target") + natGateway := &v1alpha1.NATGateway{} + natGatewayKey := client.ObjectKey{Namespace: natGatewayAutoscaler.Namespace, Name: natGatewayAutoscaler.Spec.NATGatewayRef.Name} + if err := r.Get(ctx, natGatewayKey, natGateway); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error getting NAT gateway %s: %w", natGatewayKey.Name, err) + } + log.V(1).Info("Scale target not found") + return ctrl.Result{}, nil + } + + log.V(1).Info("Managing public IPs") + if err := r.manageNATGatewayIPs(ctx, natGatewayAutoscaler, natGateway); err != nil { + if !apierrors.IsConflict(err) { + return ctrl.Result{}, fmt.Errorf("error managing public IPs: %w", err) + } + + log.V(1).Info("Conflict managing public IPs, requeueing") + return ctrl.Result{Requeue: true}, nil + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *NATGatewayAutoscalerReconciler) generateNewNATGatewayIPs(natGateway *v1alpha1.NATGateway, ct int) []v1alpha1.NATGatewayIP { + existingNames := utilslices.ToSetFunc(natGateway.Spec.IPs, func(ip v1alpha1.NATGatewayIP) string { return ip.Name }) + newNATGatewayIPs := sets.New[v1alpha1.NATGatewayIP]() + for newNATGatewayIPs.Len() != ct { + name := utilrand.String(noOfNATIPGenerateNameChars) + if !existingNames.Has(name) { + newNATGatewayIPs.Insert(v1alpha1.NATGatewayIP{Name: name}) + } + } + return newNATGatewayIPs.UnsortedList() +} + +func (r *NATGatewayAutoscalerReconciler) manageNATGatewayIPs( + ctx context.Context, + natGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, + natGateway *v1alpha1.NATGateway, +) error { + totalRequests := natGateway.Status.RequestedNATIPs + currentNoOfIPs := len(natGateway.Spec.IPs) + desiredNoOfIPs := r.determineDesiredNumberOfIPs(natGatewayAutoscaler, natGateway, currentNoOfIPs, int(totalRequests)) + diff := currentNoOfIPs - desiredNoOfIPs + + if diff < 0 { + diff *= -1 + + ips := append(make([]v1alpha1.NATGatewayIP, 0, len(natGateway.Spec.IPs)+diff), natGateway.Spec.IPs...) + ips = append(ips, r.generateNewNATGatewayIPs(natGateway, diff)...) + return r.updateNATGatewayIPs(ctx, natGateway, ips) + } else if diff > 0 { + // Delete IPs from the end since they are the 'newer' ones. + ips := natGateway.Spec.IPs[:len(natGateway.Spec.IPs)-diff] + return r.updateNATGatewayIPs(ctx, natGateway, ips) + } + return nil +} + +func (r *NATGatewayAutoscalerReconciler) updateNATGatewayIPs( + ctx context.Context, + natGateway *v1alpha1.NATGateway, + ips []v1alpha1.NATGatewayIP, +) error { + base := natGateway.DeepCopy() + natGateway.Spec.IPs = ips + return r.Patch(ctx, natGateway, client.MergeFromWithOptions(base, &client.MergeFromWithOptimisticLock{})) +} + +func (r *NATGatewayAutoscalerReconciler) determineDesiredNumberOfIPs( + natGatewayAutoscaler *v1alpha1.NATGatewayAutoscaler, + natGateway *v1alpha1.NATGateway, + totalNoOfIPs int, + totalRequests int, +) int { + slotsPerIP := int64(natgateway.SlotsPerIP(natGateway.Spec.PortsPerNetworkInterface)) + totalSlots := slotsPerIP * int64(totalNoOfIPs) + slotsDiff := totalSlots - int64(totalRequests) + ipsDiff := int(slotsDiff / slotsPerIP) + desiredNoOfPublicIPs := totalNoOfIPs - ipsDiff + + if minPublicIPs := natGatewayAutoscaler.Spec.MinPublicIPs; minPublicIPs != nil { + desiredNoOfPublicIPs = max(int(*minPublicIPs), desiredNoOfPublicIPs) + } + if maxPublicIPs := natGatewayAutoscaler.Spec.MaxPublicIPs; maxPublicIPs != nil { + desiredNoOfPublicIPs = min(int(*maxPublicIPs), desiredNoOfPublicIPs) + } + return desiredNoOfPublicIPs +} + +func (r *NATGatewayAutoscalerReconciler) enqueueByNATGateway() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + natGateway := obj.(*v1alpha1.NATGateway) + log := ctrl.LoggerFrom(ctx) + + natGatewayAutoscalerList := &v1alpha1.NATGatewayAutoscalerList{} + if err := r.List(ctx, natGatewayAutoscalerList, + client.InNamespace(natGateway.Namespace), + ); err != nil { + log.Error(err, "Error listing NAT gateway autoscalers") + return nil + } + + var reqs []ctrl.Request + for _, natGatewayAutoscaler := range natGatewayAutoscalerList.Items { + if natGatewayAutoscaler.Spec.NATGatewayRef.Name == natGateway.Name { + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&natGatewayAutoscaler)}) + } + } + return reqs + }) +} + +func (r *NATGatewayAutoscalerReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&v1alpha1.NATGatewayAutoscaler{}). + Watches( + &v1alpha1.NATGateway{}, + r.enqueueByNATGateway(), + ). + Complete(r) +} diff --git a/internal/controllers/natgatewayautoscaler_controller_test.go b/internal/controllers/natgatewayautoscaler_controller_test.go new file mode 100644 index 00000000..c420a7f6 --- /dev/null +++ b/internal/controllers/natgatewayautoscaler_controller_test.go @@ -0,0 +1,62 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api/utils/generic" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var _ = Describe("NATGatewayAutoscalerController", func() { + ns := SetupNamespace(&k8sClient) + network := SetupNetwork(ns) + + It("should add and remove public IPs depending on the demand", func(ctx SpecContext) { + By("creating a NAT gateway") + natGateway := &v1alpha1.NATGateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nat-gateway-", + }, + Spec: v1alpha1.NATGatewaySpec{ + IPFamily: corev1.IPv4Protocol, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + PortsPerNetworkInterface: 64512, + }, + } + Expect(k8sClient.Create(ctx, natGateway)).To(Succeed()) + + By("creating a NAT gateway autoscaler") + natGatewayAutoscaler := &v1alpha1.NATGatewayAutoscaler{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nat-gateway-as-", + }, + Spec: v1alpha1.NATGatewayAutoscalerSpec{ + NATGatewayRef: corev1.LocalObjectReference{ + Name: natGateway.Name, + }, + MinPublicIPs: generic.Pointer[int32](1), + MaxPublicIPs: generic.Pointer[int32](3), + }, + } + Expect(k8sClient.Create(ctx, natGatewayAutoscaler)).To(Succeed()) + }) +}) diff --git a/internal/controllers/networkidgc_controller.go b/internal/controllers/networkidgc_controller.go new file mode 100644 index 00000000..26caec78 --- /dev/null +++ b/internal/controllers/networkidgc_controller.go @@ -0,0 +1,161 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" + "k8s.io/utils/lru" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +type NetworkIDGCReconciler struct { + client.Client + APIReader client.Reader + + AbsenceCache *lru.Cache +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkids,verbs=get;list;watch;delete +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networks,verbs=get;list;watch + +func (r *NetworkIDGCReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + networkID := &v1alpha1.NetworkID{} + if err := r.Get(ctx, req.NamespacedName, networkID); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + if !networkID.DeletionTimestamp.IsZero() { + // Don't try to GC addresses that are already deleting. + return ctrl.Result{}, nil + } + + log.V(1).Info("Checking whether network ID claimer exists") + ok, err := r.networkIDClaimerExists(ctx, networkID) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error checking whether network ID claimer exists: %w", err) + } + if ok { + log.V(1).Info("Network ID claimer is still present") + return ctrl.Result{}, nil + } + + log.V(1).Info("Network ID claimer does not exist, releasing network ID") + if err := r.Delete(ctx, networkID); err != nil { + return ctrl.Result{}, fmt.Errorf("error releasing network ID: %w", err) + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *NetworkIDGCReconciler) networkIDClaimerExists(ctx context.Context, networkID *v1alpha1.NetworkID) (bool, error) { + claimRef := networkID.Spec.ClaimRef + if _, ok := r.AbsenceCache.Get(claimRef.UID); ok { + return false, nil + } + + gvr := schema.GroupVersionResource{ + Resource: claimRef.Resource, + Group: claimRef.Group, + } + resList, err := r.RESTMapper().KindsFor(gvr) + if err != nil { + return false, fmt.Errorf("error getting kinds for %s: %w", gvr.GroupResource(), err) + } + if len(resList) == 0 { + return false, fmt.Errorf("no kind for %s", gvr.GroupResource()) + } + + gvk := resList[0] + + mapping, err := r.RESTMapper().RESTMapping(gvk.GroupKind(), gvk.Version) + if err != nil { + return false, fmt.Errorf("error getting REST mapping for %s: %w", gvk, err) + } + + claimer := &metav1.PartialObjectMetadata{ + TypeMeta: metav1.TypeMeta{ + APIVersion: gvk.GroupVersion().String(), + Kind: gvk.Kind, + }, + } + claimerKey := client.ObjectKey{Name: claimRef.Name} + if mapping.Scope.Name() == meta.RESTScopeNameNamespace { + claimerKey.Namespace = claimRef.Namespace + } + + if err := r.APIReader.Get(ctx, claimerKey, claimer); err != nil { + if !apierrors.IsNotFound(err) { + return false, fmt.Errorf("error getting claiming %s %s: %w", gvk, klog.KRef(claimerKey.Namespace, claimerKey.Name), err) + } + + r.AbsenceCache.Add(claimRef.UID, nil) + return false, nil + } + return true, nil +} + +func (r *NetworkIDGCReconciler) enqueueByClaimer() handler.EventHandler { + mapAndEnqueue := func(ctx context.Context, claimer client.Object, queue workqueue.RateLimitingInterface) { + log := ctrl.LoggerFrom(ctx) + + networkIDList := &v1alpha1.NetworkIDList{} + if err := r.List(ctx, networkIDList); err != nil { + log.Error(err, "Error listing Network IDs") + return + } + + for _, networkID := range networkIDList.Items { + if v1alpha1.IsNetworkIDClaimedBy(&networkID, claimer) { + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&networkID)}) + } + } + } + + return &handler.Funcs{ + DeleteFunc: func(ctx context.Context, event event.DeleteEvent, queue workqueue.RateLimitingInterface) { + mapAndEnqueue(ctx, event.Object, queue) + }, + GenericFunc: func(ctx context.Context, event event.GenericEvent, queue workqueue.RateLimitingInterface) { + if !event.Object.GetDeletionTimestamp().IsZero() { + mapAndEnqueue(ctx, event.Object, queue) + } + }, + } +} + +func (r *NetworkIDGCReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + Named("networkidgc"). + For(&v1alpha1.NetworkID{}). + Watches( + &v1alpha1.Network{}, + r.enqueueByClaimer(), + ). + Complete(r) +} diff --git a/internal/controllers/scheduler/cache.go b/internal/controllers/scheduler/cache.go new file mode 100644 index 00000000..4af80923 --- /dev/null +++ b/internal/controllers/scheduler/cache.go @@ -0,0 +1,443 @@ +// Copyright 2023 OnMetal 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 scheduler + +import ( + "context" + "fmt" + "sync" + "time" + + "github.com/go-logr/logr" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "golang.org/x/exp/maps" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog/v2" +) + +type CacheStrategy interface { + Key(instance *v1alpha1.Instance) (types.UID, error) + ContainerKey(instance *v1alpha1.Instance) string +} + +type defaultCacheStrategy struct{} + +var DefaultCacheStrategy CacheStrategy = defaultCacheStrategy{} + +func (defaultCacheStrategy) Key(instance *v1alpha1.Instance) (types.UID, error) { + uid := instance.GetUID() + if uid == "" { + return "", fmt.Errorf("instance has no UID") + } + return uid, nil +} + +func (defaultCacheStrategy) ContainerKey(instance *v1alpha1.Instance) string { + return instance.Spec.NodeRef.Name +} + +type InstanceInfo struct { + instance *v1alpha1.Instance +} + +func (i *InstanceInfo) Instance() *v1alpha1.Instance { + return i.instance +} + +type ContainerInfo struct { + node *v1alpha1.Node + instances map[types.UID]*InstanceInfo +} + +func newNodeInfo() *ContainerInfo { + return &ContainerInfo{ + instances: make(map[types.UID]*InstanceInfo), + } +} + +func (n *ContainerInfo) Node() *v1alpha1.Node { + return n.node +} + +func (n *ContainerInfo) NumInstances() int { + return len(n.instances) +} + +func (n *ContainerInfo) Instances() []*InstanceInfo { + return maps.Values(n.instances) +} + +func (n *ContainerInfo) shallowCopy() *ContainerInfo { + return &ContainerInfo{ + node: n.node, + instances: maps.Clone(n.instances), + } +} + +type instanceState struct { + instance *v1alpha1.Instance + bindingFinished bool +} + +func NewCache(log logr.Logger, strategy CacheStrategy) *Cache { + return &Cache{ + log: log, + assumedInstances: sets.New[types.UID](), + instanceStates: make(map[types.UID]*instanceState), + nodes: make(map[string]*ContainerInfo), + strategy: strategy, + } +} + +type Cache struct { + mu sync.RWMutex + + log logr.Logger + + assumedInstances sets.Set[types.UID] + instanceStates map[types.UID]*instanceState + nodes map[string]*ContainerInfo + + strategy CacheStrategy +} + +type Snapshot struct { + cache *Cache + + nodes map[string]*ContainerInfo + nodesList []*ContainerInfo +} + +func (s *Snapshot) Update() { + s.cache.mu.RLock() + defer s.cache.mu.RUnlock() + + s.nodes = make(map[string]*ContainerInfo, len(s.cache.nodes)) + s.nodesList = make([]*ContainerInfo, 0, len(s.cache.nodes)) + for key, node := range s.cache.nodes { + if node.node == nil { + continue + } + + node := node.shallowCopy() + s.nodes[key] = node + s.nodesList = append(s.nodesList, node) + } +} + +func (s *Snapshot) NumNodes() int { + return len(s.nodesList) +} + +func (s *Snapshot) ListNodes() []*ContainerInfo { + return s.nodesList +} + +func (s *Snapshot) GetNode(name string) (*ContainerInfo, error) { + node, ok := s.nodes[name] + if !ok { + return nil, fmt.Errorf("node %q not found", name) + } + return node, nil +} + +func (c *Cache) Snapshot() *Snapshot { + snapshot := &Snapshot{cache: c} + snapshot.Update() + return snapshot +} + +func (c *Cache) IsAssumedInstance(instance *v1alpha1.Instance) (bool, error) { + key, err := c.strategy.Key(instance) + if err != nil { + return false, err + } + + c.mu.RLock() + defer c.mu.RUnlock() + return c.assumedInstances.Has(key), nil +} + +func (c *Cache) AssumeInstance(instance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(instance)) + key, err := c.strategy.Key(instance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + c.mu.Lock() + defer c.mu.Unlock() + + if _, ok := c.instanceStates[key]; ok { + return fmt.Errorf("instance %s(%v) is in the cache, so can't be assumed", key, klog.KObj(instance)) + } + + c.addInstance(log, key, instance, true) + return nil +} + +func (c *Cache) ForgetInstance(instance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(instance)) + key, err := c.strategy.Key(instance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + currState, ok := c.instanceStates[key] + if ok { + oldContainerKey := c.strategy.ContainerKey(currState.instance) + newContainerKey := c.strategy.ContainerKey(instance) + if oldContainerKey != newContainerKey { + return fmt.Errorf("instance %s(%v) was assumed on container %s but assinged to %s", key, klog.KObj(instance), newContainerKey, oldContainerKey) + } + } + + if ok && c.assumedInstances.Has(key) { + c.removeInstance(log, key, instance) + } + return fmt.Errorf("instance %s(%v) wasn't assumed so cannot be forgotten", key, klog.KObj(instance)) +} + +func (c *Cache) FinishBinding(instance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(instance)) + key, err := c.strategy.Key(instance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + c.mu.RLock() + defer c.mu.RUnlock() + + log.V(5).Info("Finished binding for instance, can be expired") + currState, ok := c.instanceStates[key] + if ok && c.assumedInstances.Has(key) { + currState.bindingFinished = true + } + return nil +} + +func (c *Cache) AddContainer(node *v1alpha1.Node) { + c.mu.Lock() + defer c.mu.Unlock() + + n, ok := c.nodes[node.Name] + if !ok { + n = newNodeInfo() + c.nodes[node.Name] = n + } + n.node = node +} + +func (c *Cache) UpdateContainer(_, newNode *v1alpha1.Node) { + c.mu.Lock() + defer c.mu.Unlock() + + n, ok := c.nodes[newNode.Name] + if !ok { + n = newNodeInfo() + c.nodes[newNode.Name] = n + } + n.node = newNode +} + +func (c *Cache) RemoveContainer(node *v1alpha1.Node) error { + c.mu.Lock() + defer c.mu.Unlock() + + n, ok := c.nodes[node.Name] + if !ok { + return fmt.Errorf("node %s not found", node.Name) + } + + n.node = nil + if len(n.instances) == 0 { + delete(c.nodes, node.Name) + } + return nil +} + +func (c *Cache) AddInstance(instance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(instance)) + key, err := c.strategy.Key(instance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + c.mu.Lock() + defer c.mu.Unlock() + + currState, ok := c.instanceStates[key] + switch { + case ok && c.assumedInstances.Has(key): + // The instance was previously assumed, but now we have actual knowledge. + c.updateInstance(log, key, currState.instance, instance) + oldContainerKey := c.strategy.ContainerKey(currState.instance) + newContainerKey := c.strategy.ContainerKey(instance) + if oldContainerKey != newContainerKey { + log.Info("Instance was added to a different container than assumed", + "AssumedContainer", oldContainerKey, + "ActualContainer", newContainerKey, + ) + } + return nil + case !ok: + // Instance was expired, add it back to the cache. + c.addInstance(log, key, instance, false) + return nil + default: + return fmt.Errorf("instance %s(%s) was already in added state", key, klog.KObj(instance)) + } +} + +func (c *Cache) UpdateInstance(oldInstance, newInstance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(oldInstance)) + key, err := c.strategy.Key(oldInstance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + c.mu.Lock() + defer c.mu.Unlock() + + currState, ok := c.instanceStates[key] + if !ok { + return fmt.Errorf("instance %s is not present in the cache and thus cannot be updated", key) + } + + if c.assumedInstances.Has(key) { + // An assumed instance won't have an Update / Remove event. It needs to have an Add event + // before an Update event, in which case the state would change from assumed to added. + return fmt.Errorf("assumed instance %s should not be updated", key) + } + + oldContainerKey := c.strategy.ContainerKey(currState.instance) + newContainerKey := c.strategy.ContainerKey(newInstance) + if oldContainerKey != newContainerKey { + // In this case, the scheduler cache is corrupted, and we cannot handle this correctly in any way - panic to + // signal abnormal exit. + err := fmt.Errorf("instance %s updated on container %s which is different than the container %s it was previously added to", + key, oldContainerKey, newContainerKey) + panic(err) + } + c.updateInstance(log, key, oldInstance, newInstance) + return nil +} + +func (c *Cache) RemoveInstance(instance *v1alpha1.Instance) error { + log := c.log.WithValues("Instance", klog.KObj(instance)) + key, err := c.strategy.Key(instance) + if err != nil { + return err + } + log = log.WithValues("InstanceKey", key) + + c.mu.Lock() + defer c.mu.Unlock() + + currState, ok := c.instanceStates[key] + if !ok { + return fmt.Errorf("instance %s not found", key) + } + + oldContainerKey := c.strategy.ContainerKey(currState.instance) + newContainerKey := c.strategy.ContainerKey(instance) + if oldContainerKey != newContainerKey { + // In this case, the scheduler cache is corrupted, and we cannot handle this correctly in any way - panic to + // signal abnormal exit. + err := fmt.Errorf("instance %s updated on container %s which is different than the container %s it was previously added to", + key, oldContainerKey, newContainerKey) + panic(err) + } + c.removeInstance(log, key, instance) + return nil +} + +func (c *Cache) updateInstance(log logr.Logger, key types.UID, oldInstance, newInstance *v1alpha1.Instance) { + c.removeInstance(log, key, oldInstance) + c.addInstance(log, key, newInstance, false) +} + +func (c *Cache) addInstance(_ logr.Logger, key types.UID, instance *v1alpha1.Instance, assume bool) { + containerKey := c.strategy.ContainerKey(instance) + n, ok := c.nodes[containerKey] + if !ok { + n = newNodeInfo() + c.nodes[containerKey] = n + } + n.instances[key] = &InstanceInfo{instance: instance} + is := &instanceState{ + instance: instance, + } + c.instanceStates[key] = is + if assume { + c.assumedInstances.Insert(key) + } +} + +func (c *Cache) removeInstance(log logr.Logger, key types.UID, instance *v1alpha1.Instance) { + containerKey := c.strategy.ContainerKey(instance) + n, ok := c.nodes[containerKey] + if !ok { + err := fmt.Errorf("container %s not found when trying to remove instance %s", containerKey, key) + log.Error(err, "Container not found") + } else { + delete(n.instances, key) + if len(n.instances) == 0 && n.node == nil { + // Garbage collect container if it's not used anymore. + delete(c.nodes, containerKey) + } + } + + c.assumedInstances.Delete(key) + delete(c.instanceStates, key) +} + +func (c *Cache) cleanupAssumedInstances() { + log := c.log + + c.mu.Lock() + defer c.mu.Unlock() + + for key := range c.assumedInstances { + log := log.WithValues("InstanceKey", key) + is, ok := c.instanceStates[key] + if !ok { + err := fmt.Errorf("instance key %s is assumed but no state recorded, potential logical error", key) + panic(err) + } + + if !is.bindingFinished { + log.V(5).Info("Won't expire cache for an instance where binding is still in progress") + continue + } + + log.V(5).Info("Removing expired instance") + c.removeInstance(log, key, is.instance) + } +} + +func (c *Cache) Start(ctx context.Context) error { + wait.UntilWithContext(ctx, func(ctx context.Context) { + c.cleanupAssumedInstances() + }, 1*time.Second) + return nil +} diff --git a/internal/controllers/scheduler_controller.go b/internal/controllers/scheduler_controller.go new file mode 100644 index 00000000..9bc8c253 --- /dev/null +++ b/internal/controllers/scheduler_controller.go @@ -0,0 +1,684 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/controllers/scheduler" + "github.com/onmetal/onmetal-api-net/internal/nodeaffinity" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/record" + "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +const ( + outOfCapacity = "OutOfCapacity" +) + +type SchedulerReconciler struct { + client.Client + record.EventRecorder + Cache *scheduler.Cache + + snapshot *scheduler.Snapshot +} + +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=instances,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nodes,verbs=get;list;watch + +func (r *SchedulerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + instance := &v1alpha1.Instance{} + if err := r.Get(ctx, req.NamespacedName, instance); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + if r.skipSchedule(log, instance) { + log.V(1).Info("Skipping scheduling for instance") + return ctrl.Result{}, nil + } + + return r.reconcileExists(ctx, log, instance) +} + +func (r *SchedulerReconciler) skipSchedule(log logr.Logger, instance *v1alpha1.Instance) bool { + if !instance.DeletionTimestamp.IsZero() { + return true + } + + isAssumed, err := r.Cache.IsAssumedInstance(instance) + if err != nil { + log.Error(err, "Error checking whether instance has been assumed") + return false + } + return isAssumed +} + +func (r *SchedulerReconciler) updateSnapshot() { + if r.snapshot == nil { + r.snapshot = r.Cache.Snapshot() + } else { + r.snapshot.Update() + } +} + +func (r *SchedulerReconciler) filterNodesByAffinity( + log logr.Logger, + inst *v1alpha1.Instance, + nodes []*scheduler.ContainerInfo, +) ([]*scheduler.ContainerInfo, error) { + if inst.Spec.Affinity == nil || inst.Spec.Affinity.NodeAffinity == nil { + // Short circuit if no affinity is specified. + return nodes, nil + } + + nodeAffinity := nodeaffinity.GetRequiredNodeAffinity(inst) + + var filtered []*scheduler.ContainerInfo + for _, node := range nodes { + ok, err := nodeAffinity.Match(node.Node()) + if err != nil { + log.Info("Node affinity match error", "Error", err) + continue + } + if !ok { + continue + } + + filtered = append(filtered, node) + } + return filtered, nil +} + +func (r *SchedulerReconciler) getExistingAntiAffinityCounts(inst *v1alpha1.Instance, nodes []*scheduler.ContainerInfo) (map[topologyPair]int, error) { + tpCount := make(map[topologyPair]int) + for _, n := range nodes { + node := n.Node() + + for _, i := range n.Instances() { + existingInst := i.Instance() + if existingInst.Namespace != inst.Namespace { + // Don't include instances from different namespaces. + continue + } + + if existingInst.Spec.Affinity == nil || existingInst.Spec.Affinity.InstanceAntiAffinity == nil { + // Don't include instances that have no instance anti-affinity. + continue + } + + antiAffinity := existingInst.Spec.Affinity.InstanceAntiAffinity + for _, term := range antiAffinity.RequiredDuringSchedulingIgnoredDuringExecution { + sel, err := metav1.LabelSelectorAsSelector(term.LabelSelector) + if err != nil { + return nil, err + } + + if sel.Matches(labels.Set(inst.Labels)) { + tpValue, ok := node.Labels[term.TopologyKey] + if !ok { + continue + } + + tpCount[topologyPair{term.TopologyKey, tpValue}] += 1 + } + } + } + } + return tpCount, nil +} + +func (r *SchedulerReconciler) getIncomingAntiAffinityCounts(inst *v1alpha1.Instance, nodes []*scheduler.ContainerInfo) (map[topologyPair]int, error) { + tpCount := make(map[topologyPair]int) + if inst.Spec.Affinity == nil || inst.Spec.Affinity.InstanceAntiAffinity == nil { + return tpCount, nil + } + + antiAffinity := inst.Spec.Affinity.InstanceAntiAffinity + + for _, n := range nodes { + node := n.Node() + + for _, i := range n.Instances() { + existingInst := i.Instance() + if existingInst.Namespace != inst.Namespace { + // Don't include instances from different namespaces. + continue + } + + for _, term := range antiAffinity.RequiredDuringSchedulingIgnoredDuringExecution { + sel, err := metav1.LabelSelectorAsSelector(term.LabelSelector) + if err != nil { + return nil, err + } + + if sel.Matches(labels.Set(existingInst.Labels)) { + tpValue, ok := node.Labels[term.TopologyKey] + if !ok { + continue + } + + tpCount[topologyPair{term.TopologyKey, tpValue}] += 1 + } + } + } + } + return tpCount, nil +} + +func (r *SchedulerReconciler) filterNodesByInstanceAntiAffinity( + log logr.Logger, + inst *v1alpha1.Instance, + nodes []*scheduler.ContainerInfo, +) ([]*scheduler.ContainerInfo, error) { + existingAntiAffinityCounts, err := r.getExistingAntiAffinityCounts(inst, nodes) + if err != nil { + return nil, err + } + + incomingAntiAffinityCounts, err := r.getIncomingAntiAffinityCounts(inst, nodes) + if err != nil { + return nil, err + } + + var filtered []*scheduler.ContainerInfo + for _, n := range nodes { + if !satisfyInstanceAntiAffinity(inst, incomingAntiAffinityCounts, n) { + continue + } + + if !satisfyExistingInstanceAntiAffinity(existingAntiAffinityCounts, n) { + continue + } + + filtered = append(filtered, n) + } + return filtered, nil +} + +func satisfyExistingInstanceAntiAffinity( + existingAntiAffinityCounts map[topologyPair]int, + nodeInfo *scheduler.ContainerInfo, +) bool { + if len(existingAntiAffinityCounts) == 0 { + return true + } + + for topologyKey, topologyValue := range nodeInfo.Node().Labels { + tp := topologyPair{key: topologyKey, value: topologyValue} + if existingAntiAffinityCounts[tp] > 0 { + return false + } + } + return true +} + +func satisfyInstanceAntiAffinity( + inst *v1alpha1.Instance, + antiAffinityCounts map[topologyPair]int, + nodeInfo *scheduler.ContainerInfo, +) bool { + if len(antiAffinityCounts) == 0 { + return true + } + + if inst.Spec.Affinity == nil || inst.Spec.Affinity.InstanceAntiAffinity == nil { + return true + } + + for _, term := range inst.Spec.Affinity.InstanceAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution { + if topologyValue, ok := nodeInfo.Node().Labels[term.TopologyKey]; ok { + tp := topologyPair{key: term.TopologyKey, value: topologyValue} + if antiAffinityCounts[tp] > 0 { + return false + } + } + } + return true +} + +// topologySpreadConstraint is an internal version for v1.TopologySpreadConstraint +// and where the selector is parsed. +type topologySpreadConstraint struct { + MaxSkew int32 + TopologyKey string + Selector labels.Selector + MinDomains int32 +} + +// nodeLabelsMatchSpreadConstraints checks if ALL topology keys in spread Constraints are present in node labels. +func nodeLabelsMatchSpreadConstraints(nodeLabels map[string]string, constraints []topologySpreadConstraint) bool { + for _, c := range constraints { + if _, ok := nodeLabels[c.TopologyKey]; !ok { + return false + } + } + return true +} + +func buildTopologySpreadConstraint(constraint *v1alpha1.TopologySpreadConstraint) (*topologySpreadConstraint, error) { + sel, err := metav1.LabelSelectorAsSelector(constraint.LabelSelector) + if err != nil { + return nil, err + } + + return &topologySpreadConstraint{ + MaxSkew: constraint.MaxSkew, + TopologyKey: constraint.TopologyKey, + Selector: sel, + MinDomains: 1, + }, nil +} + +func buildTopologySpreadConstraints(constraints []v1alpha1.TopologySpreadConstraint) ([]topologySpreadConstraint, error) { + var res []topologySpreadConstraint + for i := range constraints { + constraint := &constraints[i] + c, err := buildTopologySpreadConstraint(constraint) + if err != nil { + return nil, err + } + + res = append(res, *c) + } + return res, nil +} + +type topologyPair struct { + key string + value string +} + +type criticalPath struct { + value string + count int +} + +func (r *SchedulerReconciler) filterNodesByTopology( + log logr.Logger, + inst *v1alpha1.Instance, + nodes []*scheduler.ContainerInfo, +) ([]*scheduler.ContainerInfo, error) { + _ = log + if inst.Spec.TopologySpreadConstraints == nil { + // Short circuit if no topology spread constraints are specified. + return nodes, nil + } + + constraints, err := buildTopologySpreadConstraints(inst.Spec.TopologySpreadConstraints) + if err != nil { + return nil, err + } + + var ( + tpCounts = make(map[topologyPair]int) + tpNodes []*scheduler.ContainerInfo + ) + for _, n := range nodes { + node := n.Node() + if !nodeLabelsMatchSpreadConstraints(node.Labels, constraints) { + continue + } + + tpNodes = append(tpNodes, n) + for _, c := range constraints { + pair := topologyPair{key: c.TopologyKey, value: node.Labels[c.TopologyKey]} + count := countInstancesMatchSelector(n.Instances(), c.Selector, inst.Namespace) + tpCounts[pair] += count + } + } + + var ( + tpKeyToCriticalPath = make(map[string]criticalPath) + ) + for pair, count := range tpCounts { + cur, ok := tpKeyToCriticalPath[pair.key] + if ok && cur.count < count { + continue + } + + tpKeyToCriticalPath[pair.key] = criticalPath{ + value: pair.value, + count: count, + } + } + + var filtered []*scheduler.ContainerInfo + for _, n := range tpNodes { + node := n.Node() + + ok := true + for _, c := range constraints { + tpKey := c.TopologyKey + tpVal := node.Labels[tpKey] + + minCount := tpKeyToCriticalPath[tpKey].count + selfCount := 0 + if c.Selector.Matches(labels.Set(inst.Labels)) { + selfCount = 1 + } + + pair := topologyPair{key: tpKey, value: tpVal} + matchCount := 0 + if tpCount, ok := tpCounts[pair]; ok { + matchCount = tpCount + } + + skew := matchCount + selfCount - minCount + if skew > int(c.MaxSkew) { + ok = false + break + } + } + if !ok { + continue + } + + filtered = append(filtered, n) + } + return filtered, nil +} + +func countInstancesMatchSelector(instInfos []*scheduler.InstanceInfo, selector labels.Selector, namespace string) int { + if selector.Empty() { + return 0 + } + count := 0 + for _, i := range instInfos { + if !i.Instance().DeletionTimestamp.IsZero() || i.Instance().Namespace != namespace { + continue + } + if selector.Matches(labels.Set(i.Instance().Labels)) { + count++ + } + } + return count +} + +func (r *SchedulerReconciler) getNodesForInstance( + ctx context.Context, + log logr.Logger, + inst *v1alpha1.Instance, +) ([]*scheduler.ContainerInfo, error) { + _ = ctx + nodes := r.snapshot.ListNodes() + + var instCt int + for _, node := range nodes { + for _, i := range node.Instances() { + if i.Instance().Namespace != inst.Namespace { + continue + } + instCt++ + } + } + + filters := []func(logr.Logger, *v1alpha1.Instance, []*scheduler.ContainerInfo) ([]*scheduler.ContainerInfo, error){ + r.filterNodesByAffinity, + r.filterNodesByInstanceAntiAffinity, + r.filterNodesByTopology, + } + + var err error + for _, filter := range filters { + nodes, err = filter(log, inst, nodes) + if err != nil { + return nil, err + } + } + + return nodes, nil +} + +func (r *SchedulerReconciler) reconcileExists( + ctx context.Context, + log logr.Logger, + inst *v1alpha1.Instance, +) (ctrl.Result, error) { + r.updateSnapshot() + + nodes, err := r.getNodesForInstance(ctx, log, inst) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error getting nodes for instance: %w", err) + } + if len(nodes) == 0 { + r.EventRecorder.Event(inst, corev1.EventTypeNormal, outOfCapacity, "No nodes available to schedule instance on") + return ctrl.Result{}, nil + } + + minUsedNode := nodes[0] + for _, node := range nodes[1:] { + if node.NumInstances() < minUsedNode.NumInstances() { + minUsedNode = node + } + } + log.Info("Determined node to schedule on", + "NodeName", minUsedNode.Node().Name, + "Usage", minUsedNode.NumInstances(), + ) + + log.V(1).Info("Assuming instance to be on node") + if err := r.assume(inst, minUsedNode.Node().Name); err != nil { + return ctrl.Result{}, err + } + + log.V(1).Info("Running binding asynchronously") + go func() { + if err := r.bindingCycle(ctx, log, inst); err != nil { + if err := r.Cache.ForgetInstance(inst); err != nil { + log.Error(err, "Error forgetting instance") + } + } + }() + return ctrl.Result{}, nil +} + +func (r *SchedulerReconciler) assume(assumed *v1alpha1.Instance, nodeName string) error { + assumed.Spec.NodeRef = &corev1.LocalObjectReference{Name: nodeName} + if err := r.Cache.AssumeInstance(assumed.DeepCopy()); err != nil { + return err + } + return nil +} + +func (r *SchedulerReconciler) bindingCycle(ctx context.Context, log logr.Logger, assumedInstance *v1alpha1.Instance) error { + if err := r.bind(ctx, log, assumedInstance); err != nil { + return fmt.Errorf("error binding: %w", err) + } + return nil +} + +func (r *SchedulerReconciler) bind(ctx context.Context, log logr.Logger, assumed *v1alpha1.Instance) error { + defer func() { + if err := r.Cache.FinishBinding(assumed); err != nil { + log.Error(err, "Error finishing cache binding") + } + }() + + nonAssumed := assumed.DeepCopy() + nonAssumed.Spec.NodeRef = nil + + if err := r.Patch(ctx, assumed, client.MergeFrom(nonAssumed)); err != nil { + return fmt.Errorf("error patching instance: %w", err) + } + return nil +} + +func (r *SchedulerReconciler) instanceNotAssignedPredicate() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + instance := obj.(*v1alpha1.Instance) + return instance.Spec.NodeRef == nil + }) +} + +func (r *SchedulerReconciler) handleNode() handler.EventHandler { + return handler.Funcs{ + CreateFunc: func(ctx context.Context, evt event.CreateEvent, queue workqueue.RateLimitingInterface) { + node := evt.Object.(*v1alpha1.Node) + log := ctrl.LoggerFrom(ctx) + + r.Cache.AddContainer(node) + + // TODO: Setup an index for listing unscheduled load balancer instances for the target partition. + instanceList := &v1alpha1.InstanceList{} + if err := r.List(ctx, instanceList); err != nil { + log.Error(err, "Error listing load balancer instances") + return + } + + for _, instance := range instanceList.Items { + if !instance.DeletionTimestamp.IsZero() { + continue + } + if instance.Spec.NodeRef != nil { + continue + } + + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&instance)}) + } + }, + UpdateFunc: func(ctx context.Context, evt event.UpdateEvent, queue workqueue.RateLimitingInterface) { + oldNode := evt.ObjectOld.(*v1alpha1.Node) + newNode := evt.ObjectNew.(*v1alpha1.Node) + r.Cache.UpdateContainer(oldNode, newNode) + }, + DeleteFunc: func(ctx context.Context, evt event.DeleteEvent, queue workqueue.RateLimitingInterface) { + node := evt.Object.(*v1alpha1.Node) + log := ctrl.LoggerFrom(ctx) + + if err := r.Cache.RemoveContainer(node); err != nil { + log.Error(err, "Error removing container from cache") + } + }, + } +} + +func (r *SchedulerReconciler) isInstanceAssigned() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + instance := obj.(*v1alpha1.Instance) + return instance.Spec.NodeRef != nil + }) +} + +func (r *SchedulerReconciler) handleAssignedInstances() handler.EventHandler { + return handler.Funcs{ + CreateFunc: func(ctx context.Context, evt event.CreateEvent, queue workqueue.RateLimitingInterface) { + instance := evt.Object.(*v1alpha1.Instance) + log := ctrl.LoggerFrom(ctx) + + if err := r.Cache.AddInstance(instance); err != nil { + log.Error(err, "Error adding instance to cache") + } + }, + UpdateFunc: func(ctx context.Context, evt event.UpdateEvent, queue workqueue.RateLimitingInterface) { + oldInstance := evt.ObjectOld.(*v1alpha1.Instance) + newInstance := evt.ObjectNew.(*v1alpha1.Instance) + log := ctrl.LoggerFrom(ctx) + + // Only add or update are possible - node updates are not allowed by admission. + oldInstanceAssigned := oldInstance.Spec.NodeRef != nil + newInstanceAssigned := newInstance.Spec.NodeRef != nil + + switch { + case oldInstanceAssigned && newInstanceAssigned: + if err := r.Cache.UpdateInstance(oldInstance, newInstance); err != nil { + log.Error(err, "Error updating instance in cache") + } + case !oldInstanceAssigned && newInstanceAssigned: + if err := r.Cache.AddInstance(newInstance); err != nil { + log.Error(err, "Error adding instance to cache") + } + } + }, + DeleteFunc: func(ctx context.Context, evt event.DeleteEvent, queue workqueue.RateLimitingInterface) { + instance := evt.Object.(*v1alpha1.Instance) + log := ctrl.LoggerFrom(ctx) + + if err := r.Cache.RemoveInstance(instance); err != nil { + log.Error(err, "Error adding instance to cache") + } + }, + } +} + +func (r *SchedulerReconciler) handleUnassignedInstance() handler.EventHandler { + return handler.Funcs{ + CreateFunc: func(ctx context.Context, evt event.CreateEvent, queue workqueue.RateLimitingInterface) { + instance := evt.Object.(*v1alpha1.Instance) + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(instance)}) + }, + UpdateFunc: func(ctx context.Context, evt event.UpdateEvent, queue workqueue.RateLimitingInterface) { + oldInstance := evt.ObjectOld.(*v1alpha1.Instance) + newInstance := evt.ObjectNew.(*v1alpha1.Instance) + log := ctrl.LoggerFrom(ctx) + + if oldInstance.ResourceVersion == newInstance.ResourceVersion { + return + } + + isAssumed, err := r.Cache.IsAssumedInstance(newInstance) + if err != nil { + log.Error(err, "Error checking whether instance is assumed", "Instance", klog.KObj(newInstance)) + } + if isAssumed { + return + } + + queue.Add(ctrl.Request{NamespacedName: client.ObjectKeyFromObject(newInstance)}) + }, + } +} + +func (r *SchedulerReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + WithOptions(controller.Options{ + // Only a single concurrent reconcile since it is serialized on the scheduling algorithm's node fitting. + MaxConcurrentReconciles: 1, + }). + Named("instance-scheduler"). + Watches( + &v1alpha1.Instance{}, + r.handleUnassignedInstance(), + builder.WithPredicates( + r.instanceNotAssignedPredicate(), + ), + ). + Watches( + &v1alpha1.Instance{}, + r.handleAssignedInstances(), + builder.WithPredicates( + r.isInstanceAssigned(), + ), + ). + Watches( + &v1alpha1.Node{}, + r.handleNode(), + ). + Complete(r) +} diff --git a/internal/controllers/scheduler_controller_test.go b/internal/controllers/scheduler_controller_test.go new file mode 100644 index 00000000..e63c51be --- /dev/null +++ b/internal/controllers/scheduler_controller_test.go @@ -0,0 +1,148 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + cclient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/onmetal/onmetal-api-net/internal/controllers/scheduler" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("Scheduler", func() { + ns := SetupNamespace(&k8sClient) + + BeforeEach(func() { + By("waiting for the scheduler cache to report no nodes") + snapshot := schedulerCache.Snapshot() + Eventually(func() []*scheduler.ContainerInfo { + snapshot.Update() + return snapshot.ListNodes() + }).Should(BeEmpty()) + }) + + Context("when a node is present", func() { + node := SetupNode() + + It("should set the instance's node ref to the available node", func(ctx SpecContext) { + By("creating a load balancer instance") + loadBalancerInstance := &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-inst-", + }, + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + IPs: []net.IP{net.MustParseIP("10.0.0.1")}, + }, + } + Expect(k8sClient.Create(ctx, loadBalancerInstance)).To(Succeed()) + + By("waiting for the load balancer instance to be scheduled") + Eventually(Object(loadBalancerInstance)).Should(HaveField("Spec.NodeRef", &corev1.LocalObjectReference{ + Name: node.Name, + })) + }) + }) + + Context("when nodes with multiple topologies are present", func() { + const ( + zoneKey = "apinet.api.onmetal.de/zone" + zoneA = "zone-a" + zoneB = "zone-b" + ) + var ( + zoneANode1 = SetupNodeWithLabels(map[string]string{ + zoneKey: zoneA, + }) + zoneBNode1 = SetupNodeWithLabels(map[string]string{ + zoneKey: zoneB, + }) + ) + + It("should not schedule an instance if the instance anti affinity forbids it", func(ctx SpecContext) { + By("creating three instances to spread over the zone topology") + for i := 0; i < 3; i++ { + inst := &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "inst-", + Labels: map[string]string{ + "topology-test": "", + }, + }, + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + IPs: []net.IP{net.MustParseIP("10.0.0.1")}, + Affinity: &v1alpha1.Affinity{ + InstanceAntiAffinity: &v1alpha1.InstanceAntiAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: []v1alpha1.InstanceAffinityTerm{ + { + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"topology-test": ""}, + }, + TopologyKey: zoneKey, + }, + }, + }, + }, + }, + } + Expect(k8sClient.Create(ctx, inst)).To(Succeed()) + } + + By("waiting for two to be scheduled while one being unscheduled") + haveAllInstancesScheduledExceptOne := HaveField("Items", ConsistOf( + HaveField("Spec.NodeRef", &corev1.LocalObjectReference{Name: zoneANode1.Name}), + HaveField("Spec.NodeRef", &corev1.LocalObjectReference{Name: zoneBNode1.Name}), + HaveField("Spec.NodeRef", BeNil()), + )) + Eventually(ObjectList(&v1alpha1.InstanceList{}, cclient.InNamespace(ns.Name))).Should(haveAllInstancesScheduledExceptOne) + + By("asserting it stays that way") + Consistently(ObjectList(&v1alpha1.InstanceList{}, cclient.InNamespace(ns.Name))).Should(haveAllInstancesScheduledExceptOne) + }) + }) + + Context("when no node is present", func() { + It("leave the instance's node ref empty", func(ctx SpecContext) { + By("creating a load balancer instance") + loadBalancerInstance := &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-inst-", + }, + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + IPs: []net.IP{net.MustParseIP("10.0.0.1")}, + }, + } + Expect(k8sClient.Create(ctx, loadBalancerInstance)).To(Succeed()) + + By("waiting for the load balancer instance to be scheduled") + Consistently(Object(loadBalancerInstance)).Should(HaveField("Spec.NodeRef", BeNil())) + }) + }) +}) diff --git a/internal/controllers/util.go b/internal/controllers/util.go new file mode 100644 index 00000000..e57d292a --- /dev/null +++ b/internal/controllers/util.go @@ -0,0 +1,125 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "encoding/binary" + "fmt" + "hash/fnv" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/klog/v2" +) + +func GetTargetNodeName(inst *v1alpha1.Instance) (string, error) { + if nodeRef := inst.Spec.NodeRef; nodeRef != nil { + return nodeRef.Name, nil + } + + if inst.Spec.Affinity == nil || + inst.Spec.Affinity.NodeAffinity == nil || + inst.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil { + return "", fmt.Errorf("no spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution for load balancer instance %s", klog.KObj(inst)) + } + + terms := inst.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms + if len(terms) < 1 { + return "", fmt.Errorf("no nodeSelectorTerms in requiredDuringSchedulingIgnoredDuringExecution of load balancer instance %s", klog.KObj(inst)) + } + + for _, term := range terms { + for _, exp := range term.MatchFields { + if exp.Key == metav1.ObjectNameField && + exp.Operator == v1alpha1.NodeSelectorOpIn { + if len(exp.Values) != 1 { + return "", fmt.Errorf("the matchFields value of '%s' is not unique for load balancer instance %s", + metav1.ObjectNameField, klog.KObj(inst)) + } + + return exp.Values[0], nil + } + } + } + return "", fmt.Errorf("no node name found for load balancer instance %s", klog.KObj(inst)) +} + +// ReplaceDaemonSetInstanceNodeNameNodeAffinity replaces the RequiredDuringSchedulingIgnoredDuringExecution +// NodeAffinity of the given affinity with a new NodeAffinity that selects the given nodeName. +// Note that this function assumes that no NodeAffinity conflicts with the selected nodeName. +func ReplaceDaemonSetInstanceNodeNameNodeAffinity(affinity *v1alpha1.Affinity, nodeName string) *v1alpha1.Affinity { + nodeSelReq := v1alpha1.NodeSelectorRequirement{ + Key: metav1.ObjectNameField, + Operator: v1alpha1.NodeSelectorOpIn, + Values: []string{nodeName}, + } + + nodeSelector := &v1alpha1.NodeSelector{ + NodeSelectorTerms: []v1alpha1.NodeSelectorTerm{ + { + MatchFields: []v1alpha1.NodeSelectorRequirement{nodeSelReq}, + }, + }, + } + + if affinity == nil { + return &v1alpha1.Affinity{ + NodeAffinity: &v1alpha1.NodeAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector, + }, + } + } + + if affinity.NodeAffinity == nil { + affinity.NodeAffinity = &v1alpha1.NodeAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector, + } + return affinity + } + + nodeAffinity := affinity.NodeAffinity + + if nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil { + nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution = nodeSelector + return affinity + } + + // Replace node selector with the new one. + nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = []v1alpha1.NodeSelectorTerm{ + { + MatchFields: []v1alpha1.NodeSelectorRequirement{nodeSelReq}, + }, + } + + return affinity +} + +// ComputeHash returns a hash value calculated from pod template and +// a collisionCount to avoid hash collision. The hash will be safe encoded to +// avoid bad words. +func ComputeHash(template *v1alpha1.InstanceTemplate, collisionCount *int32) string { + podTemplateSpecHasher := fnv.New32a() + _, _ = podTemplateSpecHasher.Write([]byte(fmt.Sprintf("%#+v", *template))) + + // Add collisionCount in the hash if it exists. + if collisionCount != nil { + collisionCountBytes := make([]byte, 8) + binary.LittleEndian.PutUint32(collisionCountBytes, uint32(*collisionCount)) + _, _ = podTemplateSpecHasher.Write(collisionCountBytes) + } + + return rand.SafeEncodeString(fmt.Sprint(podTemplateSpecHasher.Sum32())) +} diff --git a/internal/natgateway/allocation.go b/internal/natgateway/allocation.go new file mode 100644 index 00000000..7cb11c6c --- /dev/null +++ b/internal/natgateway/allocation.go @@ -0,0 +1,96 @@ +// Copyright 2023 OnMetal 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 natgateway + +import ( + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api-net/utils/container" +) + +const ( + minEphemeralPort int32 = 1024 + maxEphemeralPort int32 = 65535 + noOfEphemeralPorts = maxEphemeralPort + 1 - minEphemeralPort +) + +type AllocationManager struct { + portsPerNetworkInterface int32 + slots *container.KeySlots[net.IP] +} + +func SlotsPerIP(portsPerNetworkInterface int32) int32 { + return noOfEphemeralPorts / portsPerNetworkInterface +} + +func NewAllocationManager(portsPerNetworkInterface int32, ips []net.IP) *AllocationManager { + slotsPerIP := uint(noOfEphemeralPorts / portsPerNetworkInterface) + slots := container.NewKeySlots(slotsPerIP, ips) + + return &AllocationManager{ + portsPerNetworkInterface: portsPerNetworkInterface, + slots: slots, + } +} + +func (m *AllocationManager) HasIP(ip net.IP) bool { + return m.slots.HasKey(ip) +} + +func (m *AllocationManager) endPort(port int32) int32 { + return port + m.portsPerNetworkInterface - 1 +} + +func (m *AllocationManager) slotForPorts(port, endPort int32) (uint, bool) { + if port < minEphemeralPort || port >= endPort || endPort > maxEphemeralPort { + return 0, false + } + if m.endPort(port) != endPort { + return 0, false + } + return uint((port - minEphemeralPort) / m.portsPerNetworkInterface), true +} + +func (m *AllocationManager) portsForSlot(slot uint) (port, endPort int32) { + port = int32(slot)*m.portsPerNetworkInterface + minEphemeralPort + endPort = m.endPort(port) + return port, endPort +} + +func (m *AllocationManager) Use(ip net.IP, port, endPort int32) bool { + slot, ok := m.slotForPorts(port, endPort) + if !ok { + return false + } + + return m.slots.Use(ip, slot) +} + +func (m *AllocationManager) UseNextFree() (ip net.IP, port, endPort int32, ok bool) { + ip, slot, ok := m.slots.UseNextFree() + if !ok { + return net.IP{}, 0, 0, false + } + + port, endPort = m.portsForSlot(slot) + return ip, port, endPort, true +} + +func (m *AllocationManager) Total() int64 { + return int64(m.slots.Total()) +} + +func (m *AllocationManager) Used() int64 { + return int64(m.slots.Used()) +} diff --git a/internal/natgateway/autoscaler.go b/internal/natgateway/autoscaler.go new file mode 100644 index 00000000..58442d3b --- /dev/null +++ b/internal/natgateway/autoscaler.go @@ -0,0 +1,91 @@ +// Copyright 2023 OnMetal 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 natgateway + +import ( + "sync" + + "github.com/onmetal/onmetal-api-net/utils/container" + "k8s.io/apimachinery/pkg/util/sets" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type NetworkSelector interface { + MatchesNetwork(name string) bool +} + +type networkSelector string + +func (sel networkSelector) MatchesNetwork(name string) bool { + return name == string(sel) +} + +func NoVNISelector() NetworkSelector { + return networkSelector("") +} + +func SelectNetwork(name string) NetworkSelector { + return networkSelector(name) +} + +type AutoscalerSelectors struct { + mu sync.RWMutex + + selectorByKey *container.IndexingMap[client.ObjectKey, NetworkSelector] + keysBySelectorIndex container.ReverseMapIndex[client.ObjectKey, NetworkSelector] +} + +func NewAutoscalerSelectors() *AutoscalerSelectors { + var ( + selectorByKey container.IndexingMap[client.ObjectKey, NetworkSelector] + keysBySelectorIndex = make(container.ReverseMapIndex[client.ObjectKey, NetworkSelector]) + ) + selectorByKey.AddIndex(keysBySelectorIndex) + + return &AutoscalerSelectors{ + selectorByKey: &selectorByKey, + keysBySelectorIndex: keysBySelectorIndex, + } +} + +func (m *AutoscalerSelectors) Put(key client.ObjectKey, sel NetworkSelector) { + m.mu.Lock() + defer m.mu.Unlock() + + m.selectorByKey.Put(key, sel) +} + +func (m *AutoscalerSelectors) PutIfNotPresent(key client.ObjectKey, sel NetworkSelector) { + m.mu.Lock() + defer m.mu.Unlock() + + if _, ok := m.selectorByKey.Get(key); !ok { + m.selectorByKey.Put(key, sel) + } +} + +func (m *AutoscalerSelectors) ReverseSelect(name string) sets.Set[client.ObjectKey] { + m.mu.RLock() + defer m.mu.RUnlock() + + return m.keysBySelectorIndex.Get(SelectNetwork(name)) +} + +func (m *AutoscalerSelectors) Delete(key client.ObjectKey) { + m.mu.Lock() + defer m.mu.Unlock() + + m.selectorByKey.Delete(key) +} diff --git a/internal/nodeaffinity/nodeaffinity.go b/internal/nodeaffinity/nodeaffinity.go new file mode 100644 index 00000000..754da38d --- /dev/null +++ b/internal/nodeaffinity/nodeaffinity.go @@ -0,0 +1,231 @@ +// Copyright 2023 OnMetal 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 nodeaffinity + +import ( + "errors" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/selection" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +type LazyErrorNodeSelector struct { + terms []nodeSelectorTerm +} + +type RequiredNodeAffinity struct { + nodeSelector *LazyErrorNodeSelector +} + +type nodeSelectorTerm struct { + matchLabels labels.Selector + matchFields fields.Selector + parseErrs []error +} + +func (t *nodeSelectorTerm) match(nodeLabels labels.Set, nodeFields fields.Set) (bool, []error) { + if t.parseErrs != nil { + return false, t.parseErrs + } + if t.matchLabels != nil && !t.matchLabels.Matches(nodeLabels) { + return false, nil + } + if t.matchFields != nil && len(nodeFields) > 0 && !t.matchFields.Matches(nodeFields) { + return false, nil + } + return true, nil +} + +var validSelectorOperators = []string{ + string(v1alpha1.NodeSelectorOpIn), + string(v1alpha1.NodeSelectorOpNotIn), + string(v1alpha1.NodeSelectorOpExists), + string(v1alpha1.NodeSelectorOpDoesNotExist), + string(v1alpha1.NodeSelectorOpGt), + string(v1alpha1.NodeSelectorOpLt), +} + +func nodeSelectorRequirementsAsSelector(nsm []v1alpha1.NodeSelectorRequirement, path *field.Path) (labels.Selector, []error) { + if len(nsm) == 0 { + return labels.Nothing(), nil + } + var errs []error + selector := labels.NewSelector() + for i, expr := range nsm { + p := path.Index(i) + var op selection.Operator + switch expr.Operator { + case v1alpha1.NodeSelectorOpIn: + op = selection.In + case v1alpha1.NodeSelectorOpNotIn: + op = selection.NotIn + case v1alpha1.NodeSelectorOpExists: + op = selection.Exists + case v1alpha1.NodeSelectorOpDoesNotExist: + op = selection.DoesNotExist + case v1alpha1.NodeSelectorOpGt: + op = selection.GreaterThan + case v1alpha1.NodeSelectorOpLt: + op = selection.LessThan + default: + errs = append(errs, field.NotSupported(p.Child("operator"), expr.Operator, validSelectorOperators)) + continue + } + r, err := labels.NewRequirement(expr.Key, op, expr.Values, field.WithPath(p)) + if err != nil { + errs = append(errs, err) + } else { + selector = selector.Add(*r) + } + } + if len(errs) != 0 { + return nil, errs + } + return selector, nil +} + +var validFieldSelectorOperators = []string{ + string(v1alpha1.NodeSelectorOpIn), + string(v1alpha1.NodeSelectorOpNotIn), +} + +func nodeSelectorRequirementsAsFieldSelector(nsr []v1alpha1.NodeSelectorRequirement, path *field.Path) (fields.Selector, []error) { + if len(nsr) == 0 { + return fields.Nothing(), nil + } + var errs []error + + var selectors []fields.Selector + for i, expr := range nsr { + p := path.Index(i) + switch expr.Operator { + case v1alpha1.NodeSelectorOpIn: + if len(expr.Values) != 1 { + errs = append(errs, field.Invalid(p.Child("values"), expr.Values, "must have one element")) + } else { + selectors = append(selectors, fields.OneTermEqualSelector(expr.Key, expr.Values[0])) + } + + case v1alpha1.NodeSelectorOpNotIn: + if len(expr.Values) != 1 { + errs = append(errs, field.Invalid(p.Child("values"), expr.Values, "must have one element")) + } else { + selectors = append(selectors, fields.OneTermNotEqualSelector(expr.Key, expr.Values[0])) + } + + default: + errs = append(errs, field.NotSupported(p.Child("operator"), expr.Operator, validFieldSelectorOperators)) + } + } + + if len(errs) != 0 { + return nil, errs + } + return fields.AndSelectors(selectors...), nil +} + +func newNodeSelectorTerm(term *v1alpha1.NodeSelectorTerm, path *field.Path) nodeSelectorTerm { + var ( + parsedTerm nodeSelectorTerm + errs []error + ) + if len(term.MatchExpressions) != 0 { + p := path.Child("matchExpressions") + parsedTerm.matchLabels, errs = nodeSelectorRequirementsAsSelector(term.MatchExpressions, p) + if errs != nil { + parsedTerm.parseErrs = append(parsedTerm.parseErrs, errs...) + } + } + if len(term.MatchFields) != 0 { + p := path.Child("matchField") + parsedTerm.matchFields, errs = nodeSelectorRequirementsAsFieldSelector(term.MatchFields, p) + if errs != nil { + parsedTerm.parseErrs = append(parsedTerm.parseErrs, errs...) + } + } + return parsedTerm +} + +func isEmptyNodeSelectorTerm(term *v1alpha1.NodeSelectorTerm) bool { + return len(term.MatchFields) == 0 && len(term.MatchExpressions) == 0 +} + +func (s *LazyErrorNodeSelector) Match(node *v1alpha1.Node) (bool, error) { + if node == nil { + return false, nil + } + nodeLabels := labels.Set(node.Labels) + nodeFields := extractNodeFields(node) + + var errs []error + for _, term := range s.terms { + match, tErrs := term.match(nodeLabels, nodeFields) + if len(tErrs) > 0 { + errs = append(errs, tErrs...) + continue + } + if match { + return true, nil + } + } + return false, errors.Join(errs...) +} + +func extractNodeFields(node *v1alpha1.Node) fields.Set { + f := make(fields.Set) + if len(node.Name) > 0 { + f["metadata.name"] = node.Name + } + return f +} + +func NewLazyErrorNodeSelector(ns *v1alpha1.NodeSelector) *LazyErrorNodeSelector { + p := field.ToPath() + parsedTerms := make([]nodeSelectorTerm, 0, len(ns.NodeSelectorTerms)) + path := p.Child("nodeSelectorTerms") + for i, term := range ns.NodeSelectorTerms { + if isEmptyNodeSelectorTerm(&term) { + continue + } + + p := path.Index(i) + parsedTerms = append(parsedTerms, newNodeSelectorTerm(&term, p)) + } + + return &LazyErrorNodeSelector{ + terms: parsedTerms, + } +} + +func (s RequiredNodeAffinity) Match(node *v1alpha1.Node) (bool, error) { + if s.nodeSelector != nil { + return s.nodeSelector.Match(node) + } + return true, nil +} + +func GetRequiredNodeAffinity(inst *v1alpha1.Instance) RequiredNodeAffinity { + var affinity *LazyErrorNodeSelector + if inst.Spec.Affinity != nil && + inst.Spec.Affinity.NodeAffinity != nil && + inst.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil { + affinity = NewLazyErrorNodeSelector(inst.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution) + } + + return RequiredNodeAffinity{nodeSelector: affinity} +} diff --git a/internal/registry/daemonset/storage.go b/internal/registry/daemonset/storage.go new file mode 100644 index 00000000..967d5259 --- /dev/null +++ b/internal/registry/daemonset/storage.go @@ -0,0 +1,95 @@ +// Copyright 2023 OnMetal 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 daemonset + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type DaemonSetStorage struct { + DaemonSet *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (DaemonSetStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.DaemonSet{} + }, + NewListFunc: func() runtime.Object { + return &core.DaemonSetList{} + }, + PredicateFunc: MatchDaemonSet, + DefaultQualifiedResource: core.Resource("daemonsets"), + SingularQualifiedResource: core.Resource("daemonset"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return DaemonSetStorage{}, err + } + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return DaemonSetStorage{ + DaemonSet: &REST{store}, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.DaemonSet{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/daemonset/strategy.go b/internal/registry/daemonset/strategy.go new file mode 100644 index 00000000..713018bc --- /dev/null +++ b/internal/registry/daemonset/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 daemonset + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + daemonSet, ok := obj.(*core.DaemonSet) + if !ok { + return nil, nil, fmt.Errorf("given object is not a DaemonSet") + } + return daemonSet.Labels, SelectableFields(daemonSet), nil +} + +func MatchDaemonSet(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(daemonSet *core.DaemonSet) fields.Set { + return generic.ObjectMetaFieldsSet(&daemonSet.ObjectMeta, true) +} + +type daemonSetStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) daemonSetStrategy { + return daemonSetStrategy{typer, names.SimpleNameGenerator} +} + +func (daemonSetStrategy) NamespaceScoped() bool { + return true +} + +func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + daemonSet := obj.(*core.DaemonSet) + return validation.ValidateDaemonSet(daemonSet) +} + +func (daemonSetStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (daemonSetStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (daemonSetStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (daemonSetStrategy) Canonicalize(obj runtime.Object) { +} + +func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newDaemonSet := obj.(*core.DaemonSet) + oldDaemonSet := old.(*core.DaemonSet) + return validation.ValidateDaemonSetUpdate(newDaemonSet, oldDaemonSet) +} + +func (daemonSetStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type daemonSetStatusStrategy struct { + daemonSetStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) daemonSetStatusStrategy { + return daemonSetStatusStrategy{NewStrategy(typer)} +} + +func (daemonSetStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newDaemonSet := obj.(*core.DaemonSet) + oldDaemonSet := old.(*core.DaemonSet) + newDaemonSet.Spec = oldDaemonSet.Spec +} + +func (daemonSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newDaemonSet := obj.(*core.DaemonSet) + oldDaemonSet := old.(*core.DaemonSet) + return validation.ValidateDaemonSetStatusUpdate(newDaemonSet, oldDaemonSet) +} + +func (daemonSetStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/daemonset/tableconvertor.go b/internal/registry/daemonset/tableconvertor.go new file mode 100644 index 00000000..a866319e --- /dev/null +++ b/internal/registry/daemonset/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 daemonset + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + daemonSet := obj.(*core.DaemonSet) + _ = daemonSet + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/instance/storage.go b/internal/registry/instance/storage.go new file mode 100644 index 00000000..1ab01494 --- /dev/null +++ b/internal/registry/instance/storage.go @@ -0,0 +1,95 @@ +// Copyright 2023 OnMetal 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 instance + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type InstanceStorage struct { + Instance *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (InstanceStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.Instance{} + }, + NewListFunc: func() runtime.Object { + return &core.InstanceList{} + }, + PredicateFunc: MatchInstance, + DefaultQualifiedResource: core.Resource("instances"), + SingularQualifiedResource: core.Resource("instance"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return InstanceStorage{}, err + } + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return InstanceStorage{ + Instance: &REST{store}, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.Instance{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/instance/strategy.go b/internal/registry/instance/strategy.go new file mode 100644 index 00000000..e3b9b415 --- /dev/null +++ b/internal/registry/instance/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 instance + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + instance, ok := obj.(*core.Instance) + if !ok { + return nil, nil, fmt.Errorf("given object is not a Instance") + } + return instance.Labels, SelectableFields(instance), nil +} + +func MatchInstance(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(instance *core.Instance) fields.Set { + return generic.ObjectMetaFieldsSet(&instance.ObjectMeta, true) +} + +type instanceStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) instanceStrategy { + return instanceStrategy{typer, names.SimpleNameGenerator} +} + +func (instanceStrategy) NamespaceScoped() bool { + return true +} + +func (instanceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (instanceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (instanceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + instance := obj.(*core.Instance) + return validation.ValidateInstance(instance) +} + +func (instanceStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (instanceStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (instanceStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (instanceStrategy) Canonicalize(obj runtime.Object) { +} + +func (instanceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newInstance := obj.(*core.Instance) + oldInstance := old.(*core.Instance) + return validation.ValidateInstanceUpdate(newInstance, oldInstance) +} + +func (instanceStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type instanceStatusStrategy struct { + instanceStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) instanceStatusStrategy { + return instanceStatusStrategy{NewStrategy(typer)} +} + +func (instanceStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (instanceStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newInstance := obj.(*core.Instance) + oldInstance := old.(*core.Instance) + newInstance.Spec = oldInstance.Spec +} + +func (instanceStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newInstance := obj.(*core.Instance) + oldInstance := old.(*core.Instance) + return validation.ValidateInstanceStatusUpdate(newInstance, oldInstance) +} + +func (instanceStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/instance/tableconvertor.go b/internal/registry/instance/tableconvertor.go new file mode 100644 index 00000000..9f36106e --- /dev/null +++ b/internal/registry/instance/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 instance + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + instance := obj.(*core.Instance) + _ = instance + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/ip/ipaddressallocator/ipaddressallocator.go b/internal/registry/ip/ipaddressallocator/ipaddressallocator.go new file mode 100644 index 00000000..b0733be4 --- /dev/null +++ b/internal/registry/ip/ipaddressallocator/ipaddressallocator.go @@ -0,0 +1,267 @@ +// Copyright 2023 OnMetal 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 ipaddressallocator + +import ( + "context" + "errors" + "fmt" + "math/rand" + "net/netip" + "time" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1alpha1informers "github.com/onmetal/onmetal-api-net/client-go/informers/core/v1alpha1" + v1alpha1listers "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + v1alpha1client "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + netiputils "github.com/onmetal/onmetal-api-net/utils/netip" + "go4.org/netipx" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/cache" + "k8s.io/klog/v2" + utiltrace "k8s.io/utils/trace" +) + +var ( + ErrFull = errors.New("all IPs are allocated") + ErrAllocated = errors.New("provided IP is already allocated") + ErrNotInRange = errors.New("the provided IP is not in range") +) + +type Allocator struct { + family corev1.IPFamily + + prefix netip.Prefix + firstIP netip.Addr + lastIP netip.Addr + size int64 + + client v1alpha1client.CoreV1alpha1Interface + ipAddressLister v1alpha1listers.IPAddressLister + ipAddressSynced cache.InformerSynced +} + +func New( + prefix netip.Prefix, + client v1alpha1client.CoreV1alpha1Interface, + informer v1alpha1informers.IPAddressInformer, +) (*Allocator, error) { + var family corev1.IPFamily + if prefix.Addr().Is6() { + family = corev1.IPv6Protocol + } else { + family = corev1.IPv4Protocol + } + + firstIP := prefix.Masked().Addr() + lastIP := netipx.PrefixLastIP(prefix) + size := netiputils.PrefixSize(prefix) + + return &Allocator{ + family: family, + prefix: prefix, + firstIP: firstIP, + lastIP: lastIP, + size: size, + client: client, + ipAddressLister: informer.Lister(), + ipAddressSynced: informer.Informer().HasSynced, + }, nil +} + +func (a *Allocator) IPFamily() corev1.IPFamily { + return a.family +} + +func (a *Allocator) Allocate(claimRef v1alpha1.IPAddressClaimRef, ip netip.Addr) error { + return a.allocate(claimRef, ip, false) +} + +func (a *Allocator) allocate(claimRef v1alpha1.IPAddressClaimRef, ip netip.Addr, dryRun bool) error { + if !a.ipAddressSynced() { + return fmt.Errorf("allocator not ready") + } + if !ip.IsValid() { + return fmt.Errorf("invalid IP") + } + + if ip.Less(a.firstIP) || a.lastIP.Less(ip) { + return ErrNotInRange + } + if dryRun { + return nil + } + + return a.createIPAddress(ip.String(), claimRef) +} + +func (a *Allocator) createIPAddress(name string, claimRef v1alpha1.IPAddressClaimRef) error { + ipAddress := &v1alpha1.IPAddress{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: v1alpha1.IPAddressSpec{ + ClaimRef: claimRef, + }, + } + _, err := a.client.IPAddresses().Create(context.Background(), ipAddress, metav1.CreateOptions{}) + if err != nil { + if apierrors.IsAlreadyExists(err) { + return ErrAllocated + } + return err + } + return nil +} + +func (a *Allocator) AllocateNext(claimRef v1alpha1.IPAddressClaimRef) (netip.Addr, error) { + return a.allocateNext(claimRef, false) +} + +func (a *Allocator) allocateNext(claimRef v1alpha1.IPAddressClaimRef, dryRun bool) (netip.Addr, error) { + if !a.ipAddressSynced() { + return netip.Addr{}, fmt.Errorf("allocator not ready") + } + if dryRun { + return a.prefix.Addr(), nil + } + + trace := utiltrace.New("allocate dynamic IPAddress") + defer trace.LogIfLong(500 * time.Millisecond) + + offset := rand.Int63n(a.size) + iterator := ipIterator(a.firstIP, a.lastIP, uint64(offset)) + return a.allocateFromIterator(claimRef, iterator) +} + +func (a *Allocator) allocateFromIterator(claimRef v1alpha1.IPAddressClaimRef, it func() netip.Addr) (netip.Addr, error) { + for { + addr := it() + if !addr.IsValid() { + return netip.Addr{}, ErrFull + } + + name := addr.String() + _, err := a.client.IPAddresses().Get(context.Background(), name, metav1.GetOptions{}) + if err == nil { + continue + } + + if !apierrors.IsNotFound(err) { + klog.InfoS("unexpected error", "err", err) + continue + } + + err = a.createIPAddress(name, claimRef) + if err != nil { + klog.InfoS("can not create IP address", "name", name, "err", err) + continue + } + + return addr, nil + } +} + +func (a *Allocator) Release(ip netip.Addr) error { + return a.release(ip, false) +} + +func (a *Allocator) release(ip netip.Addr, dryRun bool) error { + if !a.ipAddressSynced() { + return fmt.Errorf("allocator not ready") + } + if dryRun { + return nil + } + + name := ip.String() + err := a.client.IPAddresses().Delete(context.Background(), name, metav1.DeleteOptions{}) + if err == nil { + return nil + } + klog.InfoS("error releasing IP", "ip", ip, "err", err) + return nil +} + +func (a *Allocator) DryRun() Interface { + return dryRunAllocator{real: a} +} + +type dryRunAllocator struct { + real *Allocator +} + +func (dry dryRunAllocator) IPFamily() corev1.IPFamily { + return dry.real.IPFamily() +} + +func (dry dryRunAllocator) Allocate(claimRef v1alpha1.IPAddressClaimRef, ip netip.Addr) error { + return dry.real.allocate(claimRef, ip, true) +} + +func (dry dryRunAllocator) AllocateNext(claimRef v1alpha1.IPAddressClaimRef) (netip.Addr, error) { + return dry.real.allocateNext(claimRef, true) +} + +func (dry dryRunAllocator) Release(ip netip.Addr) error { + return dry.real.release(ip, true) +} + +func (dry dryRunAllocator) DryRun() Interface { + return dry +} + +func ipIterator(first netip.Addr, last netip.Addr, offset uint64) func() netip.Addr { + // There are no modulo operations for IP addresses + modulo := func(addr netip.Addr) netip.Addr { + if addr.Compare(last) == 1 { + return first + } + return addr + } + next := func(addr netip.Addr) netip.Addr { + return modulo(addr.Next()) + } + start, err := netiputils.AddOffsetAddress(first, offset) + if err != nil { + return func() netip.Addr { return netip.Addr{} } + } + start = modulo(start) + ip := start + seen := false + return func() netip.Addr { + value := ip + // is the last or the first iteration + if value == start { + if seen { + return netip.Addr{} + } + seen = true + } + ip = next(ip) + return value + } + +} + +type Interface interface { + IPFamily() corev1.IPFamily + Allocate(claimRef v1alpha1.IPAddressClaimRef, ip netip.Addr) error + AllocateNext(claimRef v1alpha1.IPAddressClaimRef) (netip.Addr, error) + Release(ip netip.Addr) error + DryRun() Interface +} diff --git a/internal/registry/ip/storage.go b/internal/registry/ip/storage.go new file mode 100644 index 00000000..1bf82839 --- /dev/null +++ b/internal/registry/ip/storage.go @@ -0,0 +1,154 @@ +// Copyright 2023 OnMetal 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 ip + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/registry/ip/ipaddressallocator" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/util/dryrun" + "k8s.io/klog/v2" +) + +type IPStorage struct { + IP *REST +} + +type REST struct { + *genericregistry.Store + allocatorByFamily map[corev1.IPFamily]ipaddressallocator.Interface +} + +func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, opts *metav1.CreateOptions) (genericregistry.FinishFunc, error) { + ip := obj.(*core.IP) + + alloc, ok := r.allocatorByFamily[ip.Spec.IPFamily] + if !ok { + return nil, fmt.Errorf("cannot allocate IPs of family %s", ip.Spec.IPFamily) + } + if dryrun.IsDryRun(opts.DryRun) { + alloc = alloc.DryRun() + } + + claimRef := v1alpha1.IPAddressClaimRef{ + Group: v1alpha1.GroupName, + Resource: "ips", + Namespace: ip.Namespace, + Name: ip.Name, + UID: ip.UID, + } + + addr := ip.Spec.IP + if addr.IsValid() { + if err := alloc.Allocate(claimRef, addr.Addr); err != nil { + return nil, err + } + } else { + newAddr, err := alloc.AllocateNext(claimRef) + if err != nil { + return nil, err + } + + addr = net.IP{Addr: newAddr} + ip.Spec.IP = addr + } + metav1.SetMetaDataLabel(&ip.ObjectMeta, v1alpha1.IPFamilyLabel, string(alloc.IPFamily())) + metav1.SetMetaDataLabel(&ip.ObjectMeta, v1alpha1.IPIPLabel, addr.String()) + + return func(ctx context.Context, success bool) { + if success { + klog.InfoS("allocated IP", "IP", addr) + return + } + + if err := alloc.Release(addr.Addr); err != nil { + klog.InfoS("error releasing IP", "IP", addr, "err", err) + } + }, nil +} + +func (r *REST) afterDelete(obj runtime.Object, opts *metav1.DeleteOptions) { + ip := obj.(*core.IP) + + if !dryrun.IsDryRun(opts.DryRun) { + alloc, ok := r.allocatorByFamily[ip.Spec.IPFamily] + if !ok { + return + } + + addr := ip.Spec.IP.Addr + if err := alloc.Release(addr); err != nil { + klog.InfoS("error releasing IP", "IP", addr, "err", err) + } + } +} + +func NewStorage( + scheme *runtime.Scheme, + optsGetter generic.RESTOptionsGetter, + allocatorByFamily map[corev1.IPFamily]ipaddressallocator.Interface, +) (IPStorage, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.IP{} + }, + NewListFunc: func() runtime.Object { + return &core.IPList{} + }, + PredicateFunc: MatchIP, + DefaultQualifiedResource: core.Resource("ips"), + SingularQualifiedResource: core.Resource("ip"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{ + RESTOptions: optsGetter, + AttrFunc: GetAttrs, + TriggerFunc: map[string]apisrvstorage.IndexerFunc{"spec.ip": IPTriggerFunc}, + Indexers: Indexers(), + } + if err := store.CompleteWithOptions(options); err != nil { + return IPStorage{}, err + } + + genericStore := &REST{ + Store: store, + allocatorByFamily: allocatorByFamily, + } + + store.BeginCreate = genericStore.beginCreate + store.AfterDelete = genericStore.afterDelete + + return IPStorage{ + IP: genericStore, + }, nil +} diff --git a/internal/registry/ip/strategy.go b/internal/registry/ip/strategy.go new file mode 100644 index 00000000..a1ac6c4b --- /dev/null +++ b/internal/registry/ip/strategy.go @@ -0,0 +1,122 @@ +// Copyright 2023 OnMetal 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 ip + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "k8s.io/client-go/tools/cache" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + ip, ok := obj.(*core.IP) + if !ok { + return nil, nil, fmt.Errorf("given object is not a IP") + } + return ip.Labels, SelectableFields(ip), nil +} + +func MatchIP(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + IndexFields: []string{"spec.ip"}, + } +} + +func SelectableFields(ip *core.IP) fields.Set { + fieldSet := fields.Set{ + "spec.ip": ip.Spec.IP.String(), + } + return generic.AddObjectMetaFieldsSet(fieldSet, &ip.ObjectMeta, true) +} + +func IPTriggerFunc(obj runtime.Object) string { + return obj.(*core.IP).Spec.IP.String() +} + +func IPIndexFunc(obj any) ([]string, error) { + ip, ok := obj.(*core.IP) + if !ok { + return nil, fmt.Errorf("not an ip") + } + return []string{ip.Spec.IP.String()}, nil +} + +func Indexers() *cache.Indexers { + return &cache.Indexers{ + apisrvstorage.FieldIndex("spec.ip"): IPIndexFunc, + } +} + +type ipStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) ipStrategy { + return ipStrategy{typer, names.SimpleNameGenerator} +} + +func (ipStrategy) NamespaceScoped() bool { + return true +} + +func (ipStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (ipStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (ipStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + ip := obj.(*core.IP) + return validation.ValidateIP(ip) +} + +func (ipStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (ipStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (ipStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (ipStrategy) Canonicalize(obj runtime.Object) { +} + +func (ipStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newIP := obj.(*core.IP) + oldIP := old.(*core.IP) + return validation.ValidateIPUpdate(newIP, oldIP) +} + +func (ipStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/ip/tableconvertor.go b/internal/registry/ip/tableconvertor.go new file mode 100644 index 00000000..c895568b --- /dev/null +++ b/internal/registry/ip/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 ip + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + ip := obj.(*core.IP) + _ = ip + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/ipaddress/storage.go b/internal/registry/ipaddress/storage.go new file mode 100644 index 00000000..0b0aae9f --- /dev/null +++ b/internal/registry/ipaddress/storage.go @@ -0,0 +1,61 @@ +// Copyright 2023 OnMetal 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 ipaddress + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" +) + +type IPAddressStorage struct { + IPAddress *REST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (IPAddressStorage, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.IPAddress{} + }, + NewListFunc: func() runtime.Object { + return &core.IPAddressList{} + }, + PredicateFunc: MatchIPAddress, + DefaultQualifiedResource: core.Resource("ipaddresses"), + SingularQualifiedResource: core.Resource("ipaddress"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return IPAddressStorage{}, err + } + + return IPAddressStorage{ + IPAddress: &REST{store}, + }, nil +} diff --git a/internal/registry/ipaddress/strategy.go b/internal/registry/ipaddress/strategy.go new file mode 100644 index 00000000..40913a71 --- /dev/null +++ b/internal/registry/ipaddress/strategy.go @@ -0,0 +1,99 @@ +// Copyright 2023 OnMetal 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 ipaddress + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + ipAddress, ok := obj.(*core.IPAddress) + if !ok { + return nil, nil, fmt.Errorf("given object is not a IPAddress") + } + return ipAddress.Labels, SelectableFields(ipAddress), nil +} + +func MatchIPAddress(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(ipAddress *core.IPAddress) fields.Set { + return generic.ObjectMetaFieldsSet(&ipAddress.ObjectMeta, true) +} + +type ipAddressStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) ipAddressStrategy { + return ipAddressStrategy{typer, names.SimpleNameGenerator} +} + +func (ipAddressStrategy) NamespaceScoped() bool { + return false +} + +func (ipAddressStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (ipAddressStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (ipAddressStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + ipAddress := obj.(*core.IPAddress) + return validation.ValidateIPAddress(ipAddress) +} + +func (ipAddressStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (ipAddressStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (ipAddressStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (ipAddressStrategy) Canonicalize(obj runtime.Object) { +} + +func (ipAddressStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newIPAddress := obj.(*core.IPAddress) + oldIPAddress := old.(*core.IPAddress) + return validation.ValidateIPAddressUpdate(newIPAddress, oldIPAddress) +} + +func (ipAddressStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/ipaddress/tableconvertor.go b/internal/registry/ipaddress/tableconvertor.go new file mode 100644 index 00000000..85bc450b --- /dev/null +++ b/internal/registry/ipaddress/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 ipaddress + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + ipAddress := obj.(*core.IPAddress) + _ = ipAddress + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/ipallocator/allocators.go b/internal/registry/ipallocator/allocators.go new file mode 100644 index 00000000..17596ada --- /dev/null +++ b/internal/registry/ipallocator/allocators.go @@ -0,0 +1,309 @@ +// Copyright 2023 OnMetal 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 ipallocator + +import ( + "errors" + "fmt" + "net/netip" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/utils/core" + "github.com/onmetal/onmetal-api-net/utils/iterator" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/klog/v2" +) + +type Transaction interface { + Commit() + Revert() +} + +type Request struct { + IPFamily corev1.IPFamily + Addr netip.Addr +} + +type transactionFuncs struct { + CommitFunc func() + RevertFunc func() +} + +func (f transactionFuncs) Commit() { + if f.CommitFunc != nil { + f.CommitFunc() + } +} + +func (f transactionFuncs) Revert() { + if f.RevertFunc != nil { + f.RevertFunc() + } +} + +type Accessor interface { + GetNamespace() string + GetName() string + GetUID() types.UID + GetRequests() []Request + SetIP(idx int, addr netip.Addr) +} + +type Allocators struct { + allocByFamily map[corev1.IPFamily]Interface + + gv schema.GroupVersion + kind string + resource string + + accessorFor func(obj runtime.Object) (Accessor, error) +} + +func NewAllocators( + allocByIPFamily map[corev1.IPFamily]Interface, + gv schema.GroupVersion, + kind, resource string, + accessorFor func(obj runtime.Object) (Accessor, error), +) *Allocators { + return &Allocators{ + allocByFamily: allocByIPFamily, + gv: gv, + kind: kind, + resource: resource, + accessorFor: accessorFor, + } +} + +func (a *Allocators) allocatorsForRequestIterator(it func(yield func(Request) bool) bool, dryRun bool) (map[corev1.IPFamily]Interface, error) { + var ( + allocs = make(map[corev1.IPFamily]Interface) + err error + ) + it(func(req Request) bool { + alloc, ok := a.allocByFamily[req.IPFamily] + if !ok { + err = fmt.Errorf("no allocator for IPs of family %s", req.IPFamily) + return false + } + if dryRun { + alloc = alloc.DryRun() + } + + allocs[req.IPFamily] = alloc + return len(allocs) != 2 + }) + return allocs, err +} + +func (a *Allocators) releaseIPs(allocByIPFamily map[corev1.IPFamily]Interface, namespace string, ips []netip.Addr) ([]netip.Addr, error) { + var ( + released []netip.Addr + errs []error + ) + for _, ip := range ips { + alloc := allocByIPFamily[core.IPFamilyForAddr(ip)] + if err := alloc.Release(namespace, ip); err != nil { + errs = append(errs, err) + continue + } + + released = append(released, ip) + } + return released, errors.Join(errs...) +} + +func (a *Allocators) allocateIPs(allocByFamily map[corev1.IPFamily]Interface, acc Accessor, reqs []Request) ([]netip.Addr, error) { + var allocated []netip.Addr + for _, req := range reqs { + alloc := allocByFamily[req.IPFamily] + + addr := req.Addr + claimRef := v1alpha1.IPClaimRef{ + Group: a.gv.Group, + Resource: a.resource, + Name: acc.GetName(), + UID: acc.GetUID(), + } + if addr.IsValid() { + if err := alloc.Allocate(acc.GetNamespace(), claimRef, addr); err != nil { + return allocated, err + } + } else { + newAddr, err := alloc.AllocateNext(acc.GetNamespace(), claimRef, a.gv.Version, a.kind) + if err != nil { + return allocated, err + } + + addr = newAddr + } + + allocated = append(allocated, addr) + } + return allocated, nil +} + +func (a *Allocators) AllocateCreate(obj runtime.Object, dryRun bool) (Transaction, error) { + acc, err := a.accessorFor(obj) + if err != nil { + return nil, err + } + + reqs := acc.GetRequests() + allocs, err := a.allocatorsForRequestIterator(iterator.OfSlice(reqs), dryRun) + if err != nil { + return nil, err + } + + allocated, err := a.allocateIPs(allocs, acc, reqs) + if err != nil { + return nil, err + } + + for i, ip := range allocated { + acc.SetIP(i, ip) + } + + return transactionFuncs{ + CommitFunc: func() { + if dryRun { + return + } + if len(allocated) > 0 { + klog.InfoS("Allocated IPs", "ips", allocated) + } + }, + RevertFunc: func() { + if dryRun { + return + } + + actuallyReleased, err := a.releaseIPs(allocs, acc.GetNamespace(), allocated) + if err != nil { + klog.ErrorS(err, "Error releasing IPs", + "shouldRelease", allocated, + "released", actuallyReleased, + ) + } + }, + }, nil +} + +func (a *Allocators) AllocateUpdate(obj, oldObj runtime.Object, dryRun bool) (Transaction, error) { + acc, err := a.accessorFor(obj) + if err != nil { + return nil, err + } + + oldAcc, err := a.accessorFor(oldObj) + if err != nil { + return nil, err + } + + newReqs := acc.GetRequests() + oldReqs := oldAcc.GetRequests() + + reqsIt := iterator.Concat(iterator.OfSlice(oldReqs), iterator.OfSlice(newReqs)) + allocs, err := a.allocatorsForRequestIterator(reqsIt, dryRun) + if err != nil { + return nil, err + } + + var ( + toReleaseSet = utilslices.ToSetFunc(oldReqs, func(r Request) netip.Addr { return r.Addr }) + toAllocate []Request + indexToAllocateIndex = make(map[int]int) + ) + for i, newReq := range newReqs { + if toReleaseSet.Has(newReq.Addr) { + toReleaseSet.Delete(newReq.Addr) + } else { + indexToAllocateIndex[i] = len(toAllocate) + toAllocate = append(toAllocate, newReq) + } + } + + allocated, err := a.allocateIPs(allocs, acc, toAllocate) + if err != nil { + return nil, err + } + + for idx, allocateIdx := range indexToAllocateIndex { + acc.SetIP(idx, allocated[allocateIdx]) + } + + return transactionFuncs{ + CommitFunc: func() { + if dryRun { + return + } + + if len(allocated) > 0 { + klog.InfoS("allocated IPs", "ips", allocated) + } + + toRelease := toReleaseSet.UnsortedList() + if actuallyReleased, err := a.releaseIPs(allocs, acc.GetNamespace(), toRelease); err != nil { + klog.ErrorS(err, "Error releasing IPs", + "shouldRelease", toRelease, + "released", actuallyReleased, + ) + } + }, + RevertFunc: func() { + if dryRun { + return + } + + if actuallyReleased, err := a.releaseIPs(allocs, acc.GetNamespace(), toReleaseSet.UnsortedList()); err != nil { + klog.ErrorS(err, "Error releasing IPs", + "shouldRelease", allocated, + "released", actuallyReleased, + ) + } + }, + }, nil +} + +func (a *Allocators) Release(obj runtime.Object, dryRun bool) { + acc, err := a.accessorFor(obj) + if err != nil { + klog.ErrorS(err, "Error getting accessor for object", "object", obj) + return + } + + if dryRun { + return + } + + reqs := acc.GetRequests() + allocs, err := a.allocatorsForRequestIterator(iterator.OfSlice(reqs), false) + if err != nil { + klog.ErrorS(err, "Error getting allocators") + return + } + + allocated := utilslices.Map(reqs, func(r Request) netip.Addr { return r.Addr }) + actuallyReleased, err := a.releaseIPs(allocs, acc.GetNamespace(), allocated) + if err != nil { + klog.ErrorS(err, "Error releasing IPs", + "shouldRelease", allocated, + "released", actuallyReleased, + ) + } +} diff --git a/internal/registry/ipallocator/ipallocator.go b/internal/registry/ipallocator/ipallocator.go new file mode 100644 index 00000000..28fb1974 --- /dev/null +++ b/internal/registry/ipallocator/ipallocator.go @@ -0,0 +1,303 @@ +// Copyright 2023 OnMetal 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 ipallocator + +import ( + "context" + "errors" + "fmt" + "net/netip" + "time" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1alpha1informers "github.com/onmetal/onmetal-api-net/client-go/informers/core/v1alpha1" + v1alpha1listers "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + v1alpha1client "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + "github.com/onmetal/onmetal-api/utils/generic" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/cache" + "k8s.io/klog/v2" + utiltrace "k8s.io/utils/trace" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var ( + ErrAllocated = errors.New("provided IP is already allocated") + ErrNotFound = errors.New("provided IP was not found") +) + +type Allocator struct { + prefix netip.Prefix + ipFamily corev1.IPFamily + + client v1alpha1client.CoreV1alpha1Interface + ipLister v1alpha1listers.IPLister + ipSynced cache.InformerSynced +} + +func New( + prefix netip.Prefix, + client v1alpha1client.CoreV1alpha1Interface, + informer v1alpha1informers.IPInformer, +) (*Allocator, error) { + var ipFamily corev1.IPFamily + if prefix.Addr().Is6() { + ipFamily = corev1.IPv6Protocol + } else { + ipFamily = corev1.IPv4Protocol + } + + return &Allocator{ + prefix: prefix, + ipFamily: ipFamily, + client: client, + ipLister: informer.Lister(), + ipSynced: informer.Informer().HasSynced, + }, nil +} + +func (a *Allocator) IPFamily() corev1.IPFamily { + return a.ipFamily +} + +func (a *Allocator) Allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr) error { + return a.allocate(namespace, claimRef, ip, false) +} + +func (a *Allocator) allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr, dryRun bool) error { + if !a.ipSynced() { + return fmt.Errorf("allocator not ready") + } + if !ip.IsValid() { + return fmt.Errorf("invalid IP") + } + + if dryRun { + return nil + } + + return a.claimIP(namespace, claimRef, ip) +} + +func (a *Allocator) getIPFromLister(namespace string, addr netip.Addr) (*v1alpha1.IP, error) { + ips, err := a.ipLister.IPs(namespace).List(labels.SelectorFromSet(labels.Set{ + v1alpha1.IPFamilyLabel: string(a.ipFamily), + v1alpha1.IPIPLabel: addr.String(), + })) + if err != nil { + return nil, err + } + if n := len(ips); n == 0 { + return nil, ErrNotFound + } else if n > 1 { + return nil, fmt.Errorf("multiple IPs found for address %s", addr) + } + return ips[0], nil +} + +func (a *Allocator) getIPFromClient(namespace string, addr netip.Addr) (*v1alpha1.IP, error) { + ipList, err := a.client.IPs(namespace).List(context.Background(), metav1.ListOptions{ + FieldSelector: (fields.Set{"spec.ip": addr.String()}).String(), + }) + if err != nil { + return nil, err + } + if n := len(ipList.Items); n == 0 { + return nil, ErrNotFound + } else if n > 1 { + return nil, fmt.Errorf("multiple IPs found for address %s", addr) + } + ip := ipList.Items[0] + return &ip, nil +} + +func (a *Allocator) claimIP(namespace string, claimRef v1alpha1.IPClaimRef, addr netip.Addr) error { + ip, err := a.getIPFromLister(namespace, addr) + if err != nil { + return err + } + if ip.Spec.ClaimRef != nil { + return ErrAllocated + } + + base := ip.DeepCopy() + ip.Spec.ClaimRef = &claimRef + data, err := client.StrategicMergeFrom(base).Data(ip) + if err != nil { + return err + } + + _, err = a.client.IPs(namespace).Patch(context.Background(), ip.Name, types.StrategicMergePatchType, data, metav1.PatchOptions{}) + if err == nil { + return nil + } + if apierrors.IsNotFound(err) { + return ErrNotFound + } + if apierrors.IsConflict(err) { + return ErrAllocated + } + return err +} + +func (a *Allocator) AllocateNext( + namespace string, + claimRef v1alpha1.IPClaimRef, + version, kind string, +) (netip.Addr, error) { + return a.allocateNext(namespace, claimRef, version, kind, false) +} + +func (a *Allocator) allocateNext( + namespace string, + claimRef v1alpha1.IPClaimRef, + version, kind string, + dryRun bool, +) (netip.Addr, error) { + if !a.ipSynced() { + return netip.Addr{}, fmt.Errorf("allocator not ready") + } + if dryRun { + return a.prefix.Masked().Addr(), nil + } + + trace := utiltrace.New("allocate dynamic IP") + defer trace.LogIfLong(500 * time.Millisecond) + + return a.createEphemeralIP(namespace, claimRef, version, kind) +} + +func (a *Allocator) createEphemeralIP( + namespace string, + claimRef v1alpha1.IPClaimRef, + version, kind string, +) (netip.Addr, error) { + ip, err := a.client.IPs(namespace).Create(context.Background(), &v1alpha1.IP{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: namespace, + GenerateName: claimRef.Name + "-", + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: (schema.GroupVersion{Group: claimRef.Group, Version: version}).String(), + Kind: kind, + Name: claimRef.Name, + UID: claimRef.UID, + Controller: generic.Pointer(true), + BlockOwnerDeletion: generic.Pointer(true), + }, + }, + }, + Spec: v1alpha1.IPSpec{ + Type: v1alpha1.IPTypePublic, + IPFamily: a.ipFamily, + }, + }, metav1.CreateOptions{}) + if err != nil { + return netip.Addr{}, err + } + return ip.Spec.IP.Addr, nil +} + +func (a *Allocator) Release(namespace string, ip netip.Addr) error { + return a.release(namespace, ip, false) +} + +func (a *Allocator) release(namespace string, addr netip.Addr, dryRun bool) error { + if !a.ipSynced() { + return fmt.Errorf("allocator not ready") + } + if dryRun { + return nil + } + + ip, err := a.getIPFromClient(namespace, addr) + if err != nil { + klog.ErrorS(err, "error getting IP for address", "address", addr) + return nil + } + + // If the IP is controlled, we assume it to be ephemeral. + // TODO: check on something more robust than just an owner reference. + if metav1.GetControllerOf(ip) != nil { + err := a.client.IPs(namespace).Delete(context.Background(), ip.Name, metav1.DeleteOptions{}) + if err == nil { + return nil + } + klog.ErrorS(err, "error deleting IP", "ip", klog.KObj(ip)) + return nil + } + + if err := a.releaseIP(ip); err != nil { + klog.ErrorS(err, "error releasing IP", "ip", klog.KObj(ip)) + } + return nil +} + +func (a *Allocator) releaseIP(ip *v1alpha1.IP) error { + base := ip.DeepCopy() + ip.Spec.ClaimRef = nil + data, err := client.StrategicMergeFrom(base).Data(ip) + if err != nil { + return err + } + _, err = a.client.IPs(ip.Namespace).Patch(context.Background(), ip.Name, types.StrategicMergePatchType, data, metav1.PatchOptions{}) + return err +} + +func (a *Allocator) DryRun() Interface { + return dryRunAllocator{real: a} +} + +type dryRunAllocator struct { + real *Allocator +} + +func (dry dryRunAllocator) IPFamily() corev1.IPFamily { + return dry.real.IPFamily() +} + +func (dry dryRunAllocator) Allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr) error { + return dry.real.allocate(namespace, claimRef, ip, true) +} + +func (dry dryRunAllocator) AllocateNext( + namespace string, + claimRef v1alpha1.IPClaimRef, + version, kind string, +) (netip.Addr, error) { + return dry.real.allocateNext(namespace, claimRef, version, kind, true) +} + +func (dry dryRunAllocator) Release(namespace string, ip netip.Addr) error { + return dry.real.release(namespace, ip, true) +} + +func (dry dryRunAllocator) DryRun() Interface { + return dry +} + +type Interface interface { + IPFamily() corev1.IPFamily + Allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr) error + AllocateNext(namespace string, claimRef v1alpha1.IPClaimRef, version, kind string) (netip.Addr, error) + Release(namespace string, ip netip.Addr) error + DryRun() Interface +} diff --git a/internal/registry/loadbalancer/storage.go b/internal/registry/loadbalancer/storage.go new file mode 100644 index 00000000..59a4dadd --- /dev/null +++ b/internal/registry/loadbalancer/storage.go @@ -0,0 +1,207 @@ +// Copyright 2023 OnMetal 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 loadbalancer + +import ( + "context" + "fmt" + "net/netip" + + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/registry/ipallocator" + "github.com/onmetal/onmetal-api/api/networking/v1alpha1" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "k8s.io/apiserver/pkg/util/dryrun" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type loadBalancerIPAllocatorAccessor struct { + core.LoadBalancer +} + +func (l *loadBalancerIPAllocatorAccessor) GetRequests() []ipallocator.Request { + return utilslices.Map(l.Spec.IPs, func(ip core.LoadBalancerIP) ipallocator.Request { + return ipallocator.Request{ + IPFamily: ip.IPFamily, + Addr: ip.IP.Addr, + } + }) +} + +func (l *loadBalancerIPAllocatorAccessor) SetIP(idx int, addr netip.Addr) { + l.Spec.IPs[idx].IP = net.IP{Addr: addr} +} + +func GetLoadBalancerIPAllocatorAccessor(obj runtime.Object) (ipallocator.Accessor, error) { + loadBalancer, ok := obj.(*core.LoadBalancer) + if !ok { + return nil, fmt.Errorf("object %T is not a LoadBalancer", obj) + } + + return &loadBalancerIPAllocatorAccessor{ + *loadBalancer, + }, nil +} + +type LoadBalancerStorage struct { + LoadBalancer *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store + allocators *ipallocator.Allocators +} + +func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, opts *metav1.CreateOptions) (genericregistry.FinishFunc, error) { + loadBalancer := obj.(*core.LoadBalancer) + + if loadBalancer.Spec.Type != core.LoadBalancerTypePublic { + return nil, nil + } + + dryRun := dryrun.IsDryRun(opts.DryRun) + + txn, err := r.allocators.AllocateCreate(loadBalancer, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) beginUpdate(ctx context.Context, obj, oldObj runtime.Object, opts *metav1.UpdateOptions) (genericregistry.FinishFunc, error) { + newLoadBalancer := obj.(*core.LoadBalancer) + oldLoadBalancer := oldObj.(*core.LoadBalancer) + + if newLoadBalancer.Spec.Type != core.LoadBalancerTypePublic { + return nil, nil + } + + dryRun := dryrun.IsDryRun(opts.DryRun) + txn, err := r.allocators.AllocateUpdate(newLoadBalancer, oldLoadBalancer, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) afterDelete(obj runtime.Object, opts *metav1.DeleteOptions) { + loadBalancer := obj.(*core.LoadBalancer) + + if loadBalancer.Spec.Type != core.LoadBalancerTypePublic { + return + } + + dryRun := dryrun.IsDryRun(opts.DryRun) + r.allocators.Release(loadBalancer, dryRun) +} + +func NewStorage( + scheme *runtime.Scheme, + optsGetter generic.RESTOptionsGetter, + allocatorByFamily map[corev1.IPFamily]ipallocator.Interface, +) (LoadBalancerStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.LoadBalancer{} + }, + NewListFunc: func() runtime.Object { + return &core.LoadBalancerList{} + }, + PredicateFunc: MatchLoadBalancer, + DefaultQualifiedResource: core.Resource("loadbalancers"), + SingularQualifiedResource: core.Resource("loadbalancer"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return LoadBalancerStorage{}, err + } + + genericStore := &REST{ + Store: store, + allocators: ipallocator.NewAllocators( + allocatorByFamily, + v1alpha1.SchemeGroupVersion, + "LoadBalancer", + "loadbalancers", + GetLoadBalancerIPAllocatorAccessor, + ), + } + store.BeginCreate = genericStore.beginCreate + store.BeginUpdate = genericStore.beginUpdate + store.AfterDelete = genericStore.afterDelete + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return LoadBalancerStorage{ + LoadBalancer: genericStore, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.LoadBalancer{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/loadbalancer/strategy.go b/internal/registry/loadbalancer/strategy.go new file mode 100644 index 00000000..10feb1bc --- /dev/null +++ b/internal/registry/loadbalancer/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 loadbalancer + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + loadBalancer, ok := obj.(*core.LoadBalancer) + if !ok { + return nil, nil, fmt.Errorf("given object is not a LoadBalancer") + } + return loadBalancer.Labels, SelectableFields(loadBalancer), nil +} + +func MatchLoadBalancer(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(loadBalancer *core.LoadBalancer) fields.Set { + return generic.ObjectMetaFieldsSet(&loadBalancer.ObjectMeta, true) +} + +type loadBalancerStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) loadBalancerStrategy { + return loadBalancerStrategy{typer, names.SimpleNameGenerator} +} + +func (loadBalancerStrategy) NamespaceScoped() bool { + return true +} + +func (loadBalancerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (loadBalancerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (loadBalancerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + loadBalancer := obj.(*core.LoadBalancer) + return validation.ValidateLoadBalancer(loadBalancer) +} + +func (loadBalancerStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (loadBalancerStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (loadBalancerStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (loadBalancerStrategy) Canonicalize(obj runtime.Object) { +} + +func (loadBalancerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newLoadBalancer := obj.(*core.LoadBalancer) + oldLoadBalancer := old.(*core.LoadBalancer) + return validation.ValidateLoadBalancerUpdate(newLoadBalancer, oldLoadBalancer) +} + +func (loadBalancerStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type loadBalancerStatusStrategy struct { + loadBalancerStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) loadBalancerStatusStrategy { + return loadBalancerStatusStrategy{NewStrategy(typer)} +} + +func (loadBalancerStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (loadBalancerStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newLoadBalancer := obj.(*core.LoadBalancer) + oldLoadBalancer := old.(*core.LoadBalancer) + newLoadBalancer.Spec = oldLoadBalancer.Spec +} + +func (loadBalancerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newLoadBalancer := obj.(*core.LoadBalancer) + oldLoadBalancer := old.(*core.LoadBalancer) + return validation.ValidateLoadBalancerStatusUpdate(newLoadBalancer, oldLoadBalancer) +} + +func (loadBalancerStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/loadbalancer/tableconvertor.go b/internal/registry/loadbalancer/tableconvertor.go new file mode 100644 index 00000000..8ca64e25 --- /dev/null +++ b/internal/registry/loadbalancer/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 loadbalancer + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + loadBalancer := obj.(*core.LoadBalancer) + _ = loadBalancer + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/loadbalancerrouting/storage.go b/internal/registry/loadbalancerrouting/storage.go new file mode 100644 index 00000000..dbe75675 --- /dev/null +++ b/internal/registry/loadbalancerrouting/storage.go @@ -0,0 +1,88 @@ +// Copyright 2023 OnMetal 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 loadbalancerrouting + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type LoadBalancerRoutingStorage struct { + LoadBalancerRouting *REST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (LoadBalancerRoutingStorage, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.LoadBalancerRouting{} + }, + NewListFunc: func() runtime.Object { + return &core.LoadBalancerRoutingList{} + }, + PredicateFunc: MatchLoadBalancerRouting, + DefaultQualifiedResource: core.Resource("loadbalancerroutings"), + SingularQualifiedResource: core.Resource("loadbalancerrouting"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return LoadBalancerRoutingStorage{}, err + } + + return LoadBalancerRoutingStorage{ + LoadBalancerRouting: &REST{store}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.LoadBalancerRouting{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/loadbalancerrouting/strategy.go b/internal/registry/loadbalancerrouting/strategy.go new file mode 100644 index 00000000..ff53311d --- /dev/null +++ b/internal/registry/loadbalancerrouting/strategy.go @@ -0,0 +1,99 @@ +// Copyright 2023 OnMetal 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 loadbalancerrouting + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + loadBalancerRouting, ok := obj.(*core.LoadBalancerRouting) + if !ok { + return nil, nil, fmt.Errorf("given object is not a LoadBalancerRouting") + } + return loadBalancerRouting.Labels, SelectableFields(loadBalancerRouting), nil +} + +func MatchLoadBalancerRouting(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(loadBalancerRouting *core.LoadBalancerRouting) fields.Set { + return generic.ObjectMetaFieldsSet(&loadBalancerRouting.ObjectMeta, true) +} + +type loadBalancerRoutingStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) loadBalancerRoutingStrategy { + return loadBalancerRoutingStrategy{typer, names.SimpleNameGenerator} +} + +func (loadBalancerRoutingStrategy) NamespaceScoped() bool { + return true +} + +func (loadBalancerRoutingStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (loadBalancerRoutingStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (loadBalancerRoutingStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + loadBalancerRouting := obj.(*core.LoadBalancerRouting) + return validation.ValidateLoadBalancerRouting(loadBalancerRouting) +} + +func (loadBalancerRoutingStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (loadBalancerRoutingStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (loadBalancerRoutingStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (loadBalancerRoutingStrategy) Canonicalize(obj runtime.Object) { +} + +func (loadBalancerRoutingStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newLoadBalancerRouting := obj.(*core.LoadBalancerRouting) + oldLoadBalancerRouting := old.(*core.LoadBalancerRouting) + return validation.ValidateLoadBalancerRoutingUpdate(newLoadBalancerRouting, oldLoadBalancerRouting) +} + +func (loadBalancerRoutingStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/loadbalancerrouting/tableconvertor.go b/internal/registry/loadbalancerrouting/tableconvertor.go new file mode 100644 index 00000000..bc092cf0 --- /dev/null +++ b/internal/registry/loadbalancerrouting/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 loadbalancerrouting + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + loadBalancerRouting := obj.(*core.LoadBalancerRouting) + _ = loadBalancerRouting + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/natgateway/storage.go b/internal/registry/natgateway/storage.go new file mode 100644 index 00000000..401aa0c4 --- /dev/null +++ b/internal/registry/natgateway/storage.go @@ -0,0 +1,195 @@ +// Copyright 2023 OnMetal 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 natgateway + +import ( + "context" + "fmt" + "net/netip" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/registry/ipallocator" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "k8s.io/apiserver/pkg/util/dryrun" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type natGatewayIPAllocatorAccessor struct { + core.NATGateway +} + +func (acc *natGatewayIPAllocatorAccessor) GetRequests() []ipallocator.Request { + return utilslices.Map(acc.Spec.IPs, func(ip core.NATGatewayIP) ipallocator.Request { + return ipallocator.Request{ + IPFamily: acc.Spec.IPFamily, + Addr: ip.IP.Addr, + } + }) +} + +func (acc *natGatewayIPAllocatorAccessor) SetIP(idx int, addr netip.Addr) { + acc.Spec.IPs[idx].IP = net.IP{Addr: addr} +} + +func GetNATGatewayIPAllocatorAccessor(obj runtime.Object) (ipallocator.Accessor, error) { + natGateway, ok := obj.(*core.NATGateway) + if !ok { + return nil, fmt.Errorf("object %T is not a NATGateway", obj) + } + + return &natGatewayIPAllocatorAccessor{ + *natGateway, + }, nil +} + +type NATGatewayStorage struct { + NATGateway *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store + allocators *ipallocator.Allocators +} + +func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, opts *metav1.CreateOptions) (genericregistry.FinishFunc, error) { + natGateway := obj.(*core.NATGateway) + + dryRun := dryrun.IsDryRun(opts.DryRun) + + txn, err := r.allocators.AllocateCreate(natGateway, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) beginUpdate(ctx context.Context, obj, oldObj runtime.Object, opts *metav1.UpdateOptions) (genericregistry.FinishFunc, error) { + newNATGateway := obj.(*core.NATGateway) + oldNATGateway := oldObj.(*core.NATGateway) + + dryRun := dryrun.IsDryRun(opts.DryRun) + txn, err := r.allocators.AllocateUpdate(newNATGateway, oldNATGateway, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) afterDelete(obj runtime.Object, opts *metav1.DeleteOptions) { + natGateway := obj.(*core.NATGateway) + + dryRun := dryrun.IsDryRun(opts.DryRun) + r.allocators.Release(natGateway, dryRun) +} + +func NewStorage( + scheme *runtime.Scheme, + optsGetter generic.RESTOptionsGetter, + allocByIPFamily map[corev1.IPFamily]ipallocator.Interface, +) (NATGatewayStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.NATGateway{} + }, + NewListFunc: func() runtime.Object { + return &core.NATGatewayList{} + }, + PredicateFunc: MatchNATGateway, + DefaultQualifiedResource: core.Resource("natgateways"), + SingularQualifiedResource: core.Resource("natgateway"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NATGatewayStorage{}, err + } + + genericStore := &REST{ + Store: store, + allocators: ipallocator.NewAllocators( + allocByIPFamily, + v1alpha1.SchemeGroupVersion, + "NATGateway", + "natgateways", + GetNATGatewayIPAllocatorAccessor, + ), + } + store.BeginCreate = genericStore.beginCreate + store.BeginUpdate = genericStore.beginUpdate + store.AfterDelete = genericStore.afterDelete + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return NATGatewayStorage{ + NATGateway: genericStore, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.NATGateway{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/natgateway/strategy.go b/internal/registry/natgateway/strategy.go new file mode 100644 index 00000000..1fee3994 --- /dev/null +++ b/internal/registry/natgateway/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 natgateway + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + natGateway, ok := obj.(*core.NATGateway) + if !ok { + return nil, nil, fmt.Errorf("given object is not a NATGateway") + } + return natGateway.Labels, SelectableFields(natGateway), nil +} + +func MatchNATGateway(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(natGateway *core.NATGateway) fields.Set { + return generic.ObjectMetaFieldsSet(&natGateway.ObjectMeta, true) +} + +type natGatewayStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) natGatewayStrategy { + return natGatewayStrategy{typer, names.SimpleNameGenerator} +} + +func (natGatewayStrategy) NamespaceScoped() bool { + return true +} + +func (natGatewayStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (natGatewayStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (natGatewayStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + natGateway := obj.(*core.NATGateway) + return validation.ValidateNATGateway(natGateway) +} + +func (natGatewayStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (natGatewayStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (natGatewayStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (natGatewayStrategy) Canonicalize(obj runtime.Object) { +} + +func (natGatewayStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNATGateway := obj.(*core.NATGateway) + oldNATGateway := old.(*core.NATGateway) + return validation.ValidateNATGatewayUpdate(newNATGateway, oldNATGateway) +} + +func (natGatewayStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type natGatewayStatusStrategy struct { + natGatewayStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) natGatewayStatusStrategy { + return natGatewayStatusStrategy{NewStrategy(typer)} +} + +func (natGatewayStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (natGatewayStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newNATGateway := obj.(*core.NATGateway) + oldNATGateway := old.(*core.NATGateway) + newNATGateway.Spec = oldNATGateway.Spec +} + +func (natGatewayStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNATGateway := obj.(*core.NATGateway) + oldNATGateway := old.(*core.NATGateway) + return validation.ValidateNATGatewayStatusUpdate(newNATGateway, oldNATGateway) +} + +func (natGatewayStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/natgateway/tableconvertor.go b/internal/registry/natgateway/tableconvertor.go new file mode 100644 index 00000000..91ee329f --- /dev/null +++ b/internal/registry/natgateway/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 natgateway + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + natGateway := obj.(*core.NATGateway) + _ = natGateway + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/natgatewayautoscaler/storage.go b/internal/registry/natgatewayautoscaler/storage.go new file mode 100644 index 00000000..e4187f46 --- /dev/null +++ b/internal/registry/natgatewayautoscaler/storage.go @@ -0,0 +1,95 @@ +// Copyright 2023 OnMetal 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 natgatewayautoscaler + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type NATGatewayAutoscalerStorage struct { + NATGatewayAutoscaler *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (NATGatewayAutoscalerStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.NATGatewayAutoscaler{} + }, + NewListFunc: func() runtime.Object { + return &core.NATGatewayAutoscalerList{} + }, + PredicateFunc: MatchNATGatewayAutoscaler, + DefaultQualifiedResource: core.Resource("natgatewayautoscalers"), + SingularQualifiedResource: core.Resource("natgatewayautoscaler"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NATGatewayAutoscalerStorage{}, err + } + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return NATGatewayAutoscalerStorage{ + NATGatewayAutoscaler: &REST{store}, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.NATGatewayAutoscaler{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/natgatewayautoscaler/strategy.go b/internal/registry/natgatewayautoscaler/strategy.go new file mode 100644 index 00000000..5100eec8 --- /dev/null +++ b/internal/registry/natgatewayautoscaler/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 natgatewayautoscaler + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + natGatewayAutoscaler, ok := obj.(*core.NATGatewayAutoscaler) + if !ok { + return nil, nil, fmt.Errorf("given object is not a NATGatewayAutoscaler") + } + return natGatewayAutoscaler.Labels, SelectableFields(natGatewayAutoscaler), nil +} + +func MatchNATGatewayAutoscaler(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(natGatewayAutoscaler *core.NATGatewayAutoscaler) fields.Set { + return generic.ObjectMetaFieldsSet(&natGatewayAutoscaler.ObjectMeta, true) +} + +type natGatewayAutoscalerStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) natGatewayAutoscalerStrategy { + return natGatewayAutoscalerStrategy{typer, names.SimpleNameGenerator} +} + +func (natGatewayAutoscalerStrategy) NamespaceScoped() bool { + return true +} + +func (natGatewayAutoscalerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (natGatewayAutoscalerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (natGatewayAutoscalerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + natGatewayAutoscaler := obj.(*core.NATGatewayAutoscaler) + return validation.ValidateNATGatewayAutoscaler(natGatewayAutoscaler) +} + +func (natGatewayAutoscalerStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (natGatewayAutoscalerStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (natGatewayAutoscalerStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (natGatewayAutoscalerStrategy) Canonicalize(obj runtime.Object) { +} + +func (natGatewayAutoscalerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNATGatewayAutoscaler := obj.(*core.NATGatewayAutoscaler) + oldNATGatewayAutoscaler := old.(*core.NATGatewayAutoscaler) + return validation.ValidateNATGatewayAutoscalerUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler) +} + +func (natGatewayAutoscalerStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type natGatewayAutoscalerStatusStrategy struct { + natGatewayAutoscalerStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) natGatewayAutoscalerStatusStrategy { + return natGatewayAutoscalerStatusStrategy{NewStrategy(typer)} +} + +func (natGatewayAutoscalerStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (natGatewayAutoscalerStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newNATGatewayAutoscaler := obj.(*core.NATGatewayAutoscaler) + oldNATGatewayAutoscaler := old.(*core.NATGatewayAutoscaler) + newNATGatewayAutoscaler.Spec = oldNATGatewayAutoscaler.Spec +} + +func (natGatewayAutoscalerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNATGatewayAutoscaler := obj.(*core.NATGatewayAutoscaler) + oldNATGatewayAutoscaler := old.(*core.NATGatewayAutoscaler) + return validation.ValidateNATGatewayAutoscalerStatusUpdate(newNATGatewayAutoscaler, oldNATGatewayAutoscaler) +} + +func (natGatewayAutoscalerStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/natgatewayautoscaler/tableconvertor.go b/internal/registry/natgatewayautoscaler/tableconvertor.go new file mode 100644 index 00000000..4c7712ae --- /dev/null +++ b/internal/registry/natgatewayautoscaler/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 natgatewayautoscaler + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + natGatewayAutoscaler := obj.(*core.NATGatewayAutoscaler) + _ = natGatewayAutoscaler + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/nattable/storage.go b/internal/registry/nattable/storage.go new file mode 100644 index 00000000..b624c125 --- /dev/null +++ b/internal/registry/nattable/storage.go @@ -0,0 +1,61 @@ +// Copyright 2023 OnMetal 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 nattable + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" +) + +type NATTableStorage struct { + NATTable *REST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (NATTableStorage, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.NATTable{} + }, + NewListFunc: func() runtime.Object { + return &core.NATTableList{} + }, + PredicateFunc: MatchNATTable, + DefaultQualifiedResource: core.Resource("nattables"), + SingularQualifiedResource: core.Resource("nattable"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NATTableStorage{}, err + } + + return NATTableStorage{ + NATTable: &REST{store}, + }, nil +} diff --git a/internal/registry/nattable/strategy.go b/internal/registry/nattable/strategy.go new file mode 100644 index 00000000..05b599ac --- /dev/null +++ b/internal/registry/nattable/strategy.go @@ -0,0 +1,99 @@ +// Copyright 2023 OnMetal 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 nattable + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + natTable, ok := obj.(*core.NATTable) + if !ok { + return nil, nil, fmt.Errorf("given object is not a NATTable") + } + return natTable.Labels, SelectableFields(natTable), nil +} + +func MatchNATTable(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(natTable *core.NATTable) fields.Set { + return generic.ObjectMetaFieldsSet(&natTable.ObjectMeta, true) +} + +type natTableStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) natTableStrategy { + return natTableStrategy{typer, names.SimpleNameGenerator} +} + +func (natTableStrategy) NamespaceScoped() bool { + return true +} + +func (natTableStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (natTableStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (natTableStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + natTable := obj.(*core.NATTable) + return validation.ValidateNATTable(natTable) +} + +func (natTableStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (natTableStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (natTableStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (natTableStrategy) Canonicalize(obj runtime.Object) { +} + +func (natTableStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNATTable := obj.(*core.NATTable) + oldNATTable := old.(*core.NATTable) + return validation.ValidateNATTableUpdate(newNATTable, oldNATTable) +} + +func (natTableStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/nattable/tableconvertor.go b/internal/registry/nattable/tableconvertor.go new file mode 100644 index 00000000..57754346 --- /dev/null +++ b/internal/registry/nattable/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 nattable + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + natTable := obj.(*core.NATTable) + _ = natTable + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/network/networkidallocator/networkidallocator.go b/internal/registry/network/networkidallocator/networkidallocator.go new file mode 100644 index 00000000..e1782c7b --- /dev/null +++ b/internal/registry/network/networkidallocator/networkidallocator.go @@ -0,0 +1,250 @@ +// Copyright 2023 OnMetal 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 networkidallocator + +import ( + "context" + "errors" + "fmt" + "math/rand" + "time" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + v1alpha1informers "github.com/onmetal/onmetal-api-net/client-go/informers/core/v1alpha1" + v1alpha1listers "github.com/onmetal/onmetal-api-net/client-go/listers/core/v1alpha1" + v1alpha1client "github.com/onmetal/onmetal-api-net/client-go/onmetalapinet/typed/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/networkid" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/cache" + "k8s.io/klog/v2" + utiltrace "k8s.io/utils/trace" +) + +var ( + ErrFull = errors.New("all IDs are allocated") + ErrAllocated = errors.New("provided ID is already allocated") + ErrNotInRange = errors.New("the provided ID is not in range") +) + +type Allocator struct { + minVNI int32 + maxVNI int32 + + client v1alpha1client.CoreV1alpha1Interface + networkIDLister v1alpha1listers.NetworkIDLister + networkIDSynced cache.InformerSynced +} + +func NewNetworkIDAllocator( + client v1alpha1client.CoreV1alpha1Interface, + networkIDInformer v1alpha1informers.NetworkIDInformer, + minVNI, maxVNI int32, +) (*Allocator, error) { + if minVNI < 0 || maxVNI < 0 || minVNI > maxVNI || maxVNI == 0 || minVNI == maxVNI { + return nil, fmt.Errorf("invalid min / max vnis %d/%d", minVNI, maxVNI) + } + + return &Allocator{ + minVNI: minVNI, + maxVNI: maxVNI, + client: client, + networkIDLister: networkIDInformer.Lister(), + networkIDSynced: networkIDInformer.Informer().HasSynced, + }, nil +} + +func (a *Allocator) AllocateNetwork(network *core.Network, id string) error { + return a.allocateNetwork(network, id, false) +} + +func (a *Allocator) allocateNetwork(network *core.Network, id string, dryRun bool) error { + if !a.networkIDSynced() { + return fmt.Errorf("allocator not ready") + } + + vni, err := networkid.ParseVNI(id) + if err != nil { + return err + } + + if vni < a.minVNI || vni > a.maxVNI { + return ErrNotInRange + } + if dryRun { + return nil + } + return a.createNetworkID(networkid.EncodeVNI(vni), network) +} + +func (a *Allocator) AllocateNextNetwork(network *core.Network) (string, error) { + return a.allocateNextNetwork(network, false) +} + +func (a *Allocator) allocateNextNetwork(network *core.Network, dryRun bool) (string, error) { + if !a.networkIDSynced() { + return "", fmt.Errorf("allocator not ready") + } + if dryRun { + return networkid.EncodeVNI(a.minVNI), nil + } + + trace := utiltrace.New("allocate dynamic NetworkID ID") + defer trace.LogIfLong(500 * time.Millisecond) + + start := randomVNIIteratorStart(a.minVNI, a.maxVNI) + iterator := vniIterator(a.minVNI, a.maxVNI, start) + return a.allocateFromRange(iterator, network) +} + +func (a *Allocator) allocateFromRange(iterator func() (int32, bool), network *core.Network) (string, error) { + for { + vni, ok := iterator() + if !ok { + return "", ErrFull + } + + name := networkid.EncodeVNI(vni) + _, err := a.networkIDLister.Get(name) + if err == nil { + continue + } + if !apierrors.IsNotFound(err) { + klog.InfoS("Unexpected error", "err", err) + continue + } + + err = a.createNetworkID(name, network) + if err != nil { + klog.InfoS("Cannot create network ID", "name", name, "err", err) + continue + } + + return networkid.EncodeVNI(vni), nil + } +} + +func (a *Allocator) Release(id string) error { + return a.release(id, false) +} + +func (a *Allocator) release(id string, dryRun bool) error { + if !a.networkIDSynced() { + return fmt.Errorf("allocator not ready") + } + if dryRun { + return nil + } + + name := id + err := a.client.NetworkIDs().Delete(context.Background(), name, metav1.DeleteOptions{}) + if err == nil { + return nil + } + klog.InfoS("error releasing ID", "name", name, "err", err) + return nil +} + +func (a *Allocator) DryRun() Interface { + return &dryRunAllocator{real: a} +} + +func networkToRef(network *core.Network) v1alpha1.NetworkIDClaimRef { + return v1alpha1.NetworkIDClaimRef{ + Group: core.GroupName, + Resource: "networks", + Namespace: network.Namespace, + Name: network.Name, + UID: network.UID, + } +} + +func randomVNIIteratorStart(minVNI, maxVNI int32) int32 { + diff := maxVNI - minVNI + n := rand.Int31n(diff) + return minVNI + n +} + +func vniIterator(minVNI, maxVNI, start int32) func() (int32, bool) { + var ( + next = func(vni int32) int32 { + if vni == maxVNI { + return minVNI + } + return vni + 1 + } + seen bool + vni = start + ) + + return func() (int32, bool) { + value := vni + if value == start { + if seen { + return 0, false + } + seen = true + } + vni = next(vni) + return value, true + } +} + +func (a *Allocator) createNetworkID(name string, network *core.Network) error { + networkID := v1alpha1.NetworkID{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: v1alpha1.NetworkIDSpec{ + ClaimRef: networkToRef(network), + }, + } + _, err := a.client.NetworkIDs().Create(context.Background(), &networkID, metav1.CreateOptions{}) + if err != nil { + if apierrors.IsAlreadyExists(err) { + return ErrAllocated + } + return err + } + return nil +} + +type dryRunAllocator struct { + real *Allocator +} + +func (dry dryRunAllocator) AllocateNetwork(network *core.Network, id string) error { + return dry.real.allocateNetwork(network, id, true) +} + +func (dry dryRunAllocator) AllocateNextNetwork(network *core.Network) (string, error) { + return dry.real.allocateNextNetwork(network, true) +} + +func (dry dryRunAllocator) Release(id string) error { + return dry.real.release(id, true) +} + +func (dry dryRunAllocator) DryRun() Interface { + return dry +} + +type Interface interface { + AllocateNetwork(network *core.Network, id string) error + AllocateNextNetwork(network *core.Network) (string, error) + Release(id string) error + DryRun() Interface +} diff --git a/internal/registry/network/storage.go b/internal/registry/network/storage.go new file mode 100644 index 00000000..3284c8cd --- /dev/null +++ b/internal/registry/network/storage.go @@ -0,0 +1,156 @@ +// Copyright 2023 OnMetal 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 network + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/registry/network/networkidallocator" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "k8s.io/apiserver/pkg/util/dryrun" + "k8s.io/klog/v2" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type NetworkStorage struct { + Network *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store + allocator networkidallocator.Interface +} + +func NewStorage( + scheme *runtime.Scheme, + optsGetter generic.RESTOptionsGetter, + allocator networkidallocator.Interface, +) (NetworkStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.Network{} + }, + NewListFunc: func() runtime.Object { + return &core.NetworkList{} + }, + PredicateFunc: MatchNetwork, + DefaultQualifiedResource: core.Resource("networks"), + SingularQualifiedResource: core.Resource("network"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NetworkStorage{}, err + } + + genericStore := &REST{ + Store: store, + allocator: allocator, + } + store.BeginCreate = genericStore.beginCreate + store.AfterDelete = genericStore.afterDelete + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return NetworkStorage{ + Network: genericStore, + Status: &StatusREST{&statusStore}, + }, nil +} + +func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, options *metav1.CreateOptions) (genericregistry.FinishFunc, error) { + network := obj.(*core.Network) + + dryRun := dryrun.IsDryRun(options.DryRun) + allocator := r.allocator + if dryRun { + allocator = allocator.DryRun() + } + + id := network.Spec.ID + if id != "" { + if err := allocator.AllocateNetwork(network, id); err != nil { + return nil, err + } + } else { + newID, err := allocator.AllocateNextNetwork(network) + if err != nil { + return nil, err + } + + id = newID + network.Spec.ID = id + } + return func(ctx context.Context, success bool) { + if success { + klog.InfoS("Allocated network ID", "id", id) + return + } + + if err := allocator.Release(id); err != nil { + klog.InfoS("Error releasing network ID", "id", id, "err", err) + } + }, nil +} + +func (r *REST) afterDelete(obj runtime.Object, options *metav1.DeleteOptions) { + network := obj.(*core.Network) + + if !dryrun.IsDryRun(options.DryRun) { + id := network.Spec.ID + if err := r.allocator.Release(id); err != nil { + klog.InfoS("Error releasing network ID", "id", id, "err", err) + } + } +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.Network{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/network/strategy.go b/internal/registry/network/strategy.go new file mode 100644 index 00000000..87fc9b82 --- /dev/null +++ b/internal/registry/network/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 network + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + network, ok := obj.(*core.Network) + if !ok { + return nil, nil, fmt.Errorf("given object is not a Network") + } + return network.Labels, SelectableFields(network), nil +} + +func MatchNetwork(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(network *core.Network) fields.Set { + return generic.ObjectMetaFieldsSet(&network.ObjectMeta, true) +} + +type networkStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) networkStrategy { + return networkStrategy{typer, names.SimpleNameGenerator} +} + +func (networkStrategy) NamespaceScoped() bool { + return true +} + +func (networkStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (networkStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (networkStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + network := obj.(*core.Network) + return validation.ValidateNetwork(network) +} + +func (networkStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (networkStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (networkStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (networkStrategy) Canonicalize(obj runtime.Object) { +} + +func (networkStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNetwork := obj.(*core.Network) + oldNetwork := old.(*core.Network) + return validation.ValidateNetworkUpdate(newNetwork, oldNetwork) +} + +func (networkStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type networkStatusStrategy struct { + networkStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) networkStatusStrategy { + return networkStatusStrategy{NewStrategy(typer)} +} + +func (networkStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (networkStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newNetwork := obj.(*core.Network) + oldNetwork := old.(*core.Network) + newNetwork.Spec = oldNetwork.Spec +} + +func (networkStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNetwork := obj.(*core.Network) + oldNetwork := old.(*core.Network) + return validation.ValidateNetworkStatusUpdate(newNetwork, oldNetwork) +} + +func (networkStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/network/tableconvertor.go b/internal/registry/network/tableconvertor.go new file mode 100644 index 00000000..88060c7c --- /dev/null +++ b/internal/registry/network/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 network + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + network := obj.(*core.Network) + _ = network + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/networkid/storage.go b/internal/registry/networkid/storage.go new file mode 100644 index 00000000..611d1fcd --- /dev/null +++ b/internal/registry/networkid/storage.go @@ -0,0 +1,61 @@ +// Copyright 2023 OnMetal 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 networkid + +import ( + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" +) + +type NetworkIDStorage struct { + NetworkID *REST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (NetworkIDStorage, error) { + strategy := NewStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.NetworkID{} + }, + NewListFunc: func() runtime.Object { + return &core.NetworkIDList{} + }, + PredicateFunc: MatchNetworkID, + DefaultQualifiedResource: core.Resource("networkids"), + SingularQualifiedResource: core.Resource("networkid"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NetworkIDStorage{}, err + } + + return NetworkIDStorage{ + NetworkID: &REST{store}, + }, nil +} diff --git a/internal/registry/networkid/strategy.go b/internal/registry/networkid/strategy.go new file mode 100644 index 00000000..dd615208 --- /dev/null +++ b/internal/registry/networkid/strategy.go @@ -0,0 +1,99 @@ +// Copyright 2023 OnMetal 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 networkid + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + networkID, ok := obj.(*core.NetworkID) + if !ok { + return nil, nil, fmt.Errorf("given object is not a NetworkID") + } + return networkID.Labels, SelectableFields(networkID), nil +} + +func MatchNetworkID(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(networkID *core.NetworkID) fields.Set { + return generic.ObjectMetaFieldsSet(&networkID.ObjectMeta, true) +} + +type networkIDStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) networkIDStrategy { + return networkIDStrategy{typer, names.SimpleNameGenerator} +} + +func (networkIDStrategy) NamespaceScoped() bool { + return false +} + +func (networkIDStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (networkIDStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (networkIDStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + networkID := obj.(*core.NetworkID) + return validation.ValidateNetworkID(networkID) +} + +func (networkIDStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (networkIDStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (networkIDStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (networkIDStrategy) Canonicalize(obj runtime.Object) { +} + +func (networkIDStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNetworkID := obj.(*core.NetworkID) + oldNetworkID := old.(*core.NetworkID) + return validation.ValidateNetworkIDUpdate(newNetworkID, oldNetworkID) +} + +func (networkIDStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/networkid/tableconvertor.go b/internal/registry/networkid/tableconvertor.go new file mode 100644 index 00000000..ddf73063 --- /dev/null +++ b/internal/registry/networkid/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 networkid + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + networkID := obj.(*core.NetworkID) + _ = networkID + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/networkinterface/storage.go b/internal/registry/networkinterface/storage.go new file mode 100644 index 00000000..c740654d --- /dev/null +++ b/internal/registry/networkinterface/storage.go @@ -0,0 +1,195 @@ +// Copyright 2023 OnMetal 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 networkinterface + +import ( + "context" + "fmt" + "net/netip" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/registry/ipallocator" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "k8s.io/apiserver/pkg/util/dryrun" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type networkInterfaceIPAllocatorAccessor struct { + core.NetworkInterface +} + +func (acc *networkInterfaceIPAllocatorAccessor) GetRequests() []ipallocator.Request { + return utilslices.Map(acc.Spec.PublicIPs, func(ip core.NetworkInterfacePublicIP) ipallocator.Request { + return ipallocator.Request{ + IPFamily: ip.IPFamily, + Addr: ip.IP.Addr, + } + }) +} + +func (acc *networkInterfaceIPAllocatorAccessor) SetIP(idx int, addr netip.Addr) { + acc.Spec.PublicIPs[idx].IP = net.IP{Addr: addr} +} + +func GetNetworkInterfaceIPAllocatorAccessor(obj runtime.Object) (ipallocator.Accessor, error) { + networkInterface, ok := obj.(*core.NetworkInterface) + if !ok { + return nil, fmt.Errorf("object %T is not a NetworkInterface", obj) + } + + return &networkInterfaceIPAllocatorAccessor{ + *networkInterface, + }, nil +} + +type NetworkInterfaceStorage struct { + NetworkInterface *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store + allocators *ipallocator.Allocators +} + +func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, opts *metav1.CreateOptions) (genericregistry.FinishFunc, error) { + networkInterface := obj.(*core.NetworkInterface) + + dryRun := dryrun.IsDryRun(opts.DryRun) + + txn, err := r.allocators.AllocateCreate(networkInterface, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) beginUpdate(ctx context.Context, obj, oldObj runtime.Object, opts *metav1.UpdateOptions) (genericregistry.FinishFunc, error) { + newNetworkInterface := obj.(*core.NetworkInterface) + oldNetworkInterface := oldObj.(*core.NetworkInterface) + + dryRun := dryrun.IsDryRun(opts.DryRun) + txn, err := r.allocators.AllocateUpdate(newNetworkInterface, oldNetworkInterface, dryRun) + if err != nil { + return nil, err + } + + return func(ctx context.Context, success bool) { + if success { + txn.Commit() + } else { + txn.Revert() + } + }, nil +} + +func (r *REST) afterDelete(obj runtime.Object, opts *metav1.DeleteOptions) { + networkInterface := obj.(*core.NetworkInterface) + + dryRun := dryrun.IsDryRun(opts.DryRun) + r.allocators.Release(networkInterface, dryRun) +} + +func NewStorage( + scheme *runtime.Scheme, + optsGetter generic.RESTOptionsGetter, + allocatorByFamily map[corev1.IPFamily]ipallocator.Interface, +) (NetworkInterfaceStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.NetworkInterface{} + }, + NewListFunc: func() runtime.Object { + return &core.NetworkInterfaceList{} + }, + PredicateFunc: MatchNetworkInterface, + DefaultQualifiedResource: core.Resource("networkinterfaces"), + SingularQualifiedResource: core.Resource("networkinterface"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NetworkInterfaceStorage{}, err + } + + genericStore := &REST{ + Store: store, + allocators: ipallocator.NewAllocators( + allocatorByFamily, + v1alpha1.SchemeGroupVersion, + "NetworkInterface", + "networkinterfaces", + GetNetworkInterfaceIPAllocatorAccessor, + ), + } + store.BeginCreate = genericStore.beginCreate + store.BeginUpdate = genericStore.beginUpdate + store.AfterDelete = genericStore.afterDelete + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return NetworkInterfaceStorage{ + NetworkInterface: genericStore, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.NetworkInterface{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/networkinterface/strategy.go b/internal/registry/networkinterface/strategy.go new file mode 100644 index 00000000..a0bdd4c8 --- /dev/null +++ b/internal/registry/networkinterface/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 networkinterface + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + networkInterface, ok := obj.(*core.NetworkInterface) + if !ok { + return nil, nil, fmt.Errorf("given object is not a NetworkInterface") + } + return networkInterface.Labels, SelectableFields(networkInterface), nil +} + +func MatchNetworkInterface(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(networkInterface *core.NetworkInterface) fields.Set { + return generic.ObjectMetaFieldsSet(&networkInterface.ObjectMeta, true) +} + +type networkInterfaceStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) networkInterfaceStrategy { + return networkInterfaceStrategy{typer, names.SimpleNameGenerator} +} + +func (networkInterfaceStrategy) NamespaceScoped() bool { + return true +} + +func (networkInterfaceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (networkInterfaceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (networkInterfaceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + networkInterface := obj.(*core.NetworkInterface) + return validation.ValidateNetworkInterface(networkInterface) +} + +func (networkInterfaceStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (networkInterfaceStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (networkInterfaceStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (networkInterfaceStrategy) Canonicalize(obj runtime.Object) { +} + +func (networkInterfaceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNetworkInterface := obj.(*core.NetworkInterface) + oldNetworkInterface := old.(*core.NetworkInterface) + return validation.ValidateNetworkInterfaceUpdate(newNetworkInterface, oldNetworkInterface) +} + +func (networkInterfaceStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type networkInterfaceStatusStrategy struct { + networkInterfaceStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) networkInterfaceStatusStrategy { + return networkInterfaceStatusStrategy{NewStrategy(typer)} +} + +func (networkInterfaceStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (networkInterfaceStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newNetworkInterface := obj.(*core.NetworkInterface) + oldNetworkInterface := old.(*core.NetworkInterface) + newNetworkInterface.Spec = oldNetworkInterface.Spec +} + +func (networkInterfaceStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNetworkInterface := obj.(*core.NetworkInterface) + oldNetworkInterface := old.(*core.NetworkInterface) + return validation.ValidateNetworkInterfaceStatusUpdate(newNetworkInterface, oldNetworkInterface) +} + +func (networkInterfaceStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/networkinterface/tableconvertor.go b/internal/registry/networkinterface/tableconvertor.go new file mode 100644 index 00000000..b5147f84 --- /dev/null +++ b/internal/registry/networkinterface/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 networkinterface + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + networkInterface := obj.(*core.NetworkInterface) + _ = networkInterface + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/internal/registry/node/storage.go b/internal/registry/node/storage.go new file mode 100644 index 00000000..281be947 --- /dev/null +++ b/internal/registry/node/storage.go @@ -0,0 +1,95 @@ +// Copyright 2023 OnMetal 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 node + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +type NodeStorage struct { + Node *REST + Status *StatusREST +} + +type REST struct { + *genericregistry.Store +} + +func NewStorage(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (NodeStorage, error) { + strategy := NewStrategy(scheme) + statusStrategy := NewStatusStrategy(scheme) + + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { + return &core.Node{} + }, + NewListFunc: func() runtime.Object { + return &core.NodeList{} + }, + PredicateFunc: MatchNode, + DefaultQualifiedResource: core.Resource("nodes"), + SingularQualifiedResource: core.Resource("node"), + + CreateStrategy: strategy, + UpdateStrategy: strategy, + DeleteStrategy: strategy, + + TableConvertor: newTableConvertor(), + } + + options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} + if err := store.CompleteWithOptions(options); err != nil { + return NodeStorage{}, err + } + + statusStore := *store + statusStore.UpdateStrategy = statusStrategy + statusStore.ResetFieldsStrategy = statusStrategy + + return NodeStorage{ + Node: &REST{store}, + Status: &StatusREST{&statusStore}, + }, nil +} + +type StatusREST struct { + store *genericregistry.Store +} + +func (r *StatusREST) New() runtime.Object { + return &core.Node{} +} + +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return r.store.GetResetFields() +} + +func (r *StatusREST) Destroy() {} diff --git a/internal/registry/node/strategy.go b/internal/registry/node/strategy.go new file mode 100644 index 00000000..ebca11d9 --- /dev/null +++ b/internal/registry/node/strategy.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 node + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "github.com/onmetal/onmetal-api-net/internal/apis/core/validation" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/registry/generic" + apisrvstorage "k8s.io/apiserver/pkg/storage" + "k8s.io/apiserver/pkg/storage/names" + "sigs.k8s.io/structured-merge-diff/v4/fieldpath" +) + +func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { + node, ok := obj.(*core.Node) + if !ok { + return nil, nil, fmt.Errorf("given object is not a Node") + } + return node.Labels, SelectableFields(node), nil +} + +func MatchNode(label labels.Selector, field fields.Selector) apisrvstorage.SelectionPredicate { + return apisrvstorage.SelectionPredicate{ + Label: label, + Field: field, + GetAttrs: GetAttrs, + } +} + +func SelectableFields(node *core.Node) fields.Set { + return generic.ObjectMetaFieldsSet(&node.ObjectMeta, true) +} + +type nodeStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +func NewStrategy(typer runtime.ObjectTyper) nodeStrategy { + return nodeStrategy{typer, names.SimpleNameGenerator} +} + +func (nodeStrategy) NamespaceScoped() bool { + return false +} + +func (nodeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { +} + +func (nodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { +} + +func (nodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + node := obj.(*core.Node) + return validation.ValidateNode(node) +} + +func (nodeStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { + return nil +} + +func (nodeStrategy) AllowCreateOnUpdate() bool { + return false +} + +func (nodeStrategy) AllowUnconditionalUpdate() bool { + return false +} + +func (nodeStrategy) Canonicalize(obj runtime.Object) { +} + +func (nodeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNode := obj.(*core.Node) + oldNode := old.(*core.Node) + return validation.ValidateNodeUpdate(newNode, oldNode) +} + +func (nodeStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { + return nil +} + +type nodeStatusStrategy struct { + nodeStrategy +} + +func NewStatusStrategy(typer runtime.ObjectTyper) nodeStatusStrategy { + return nodeStatusStrategy{NewStrategy(typer)} +} + +func (nodeStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { + return map[fieldpath.APIVersion]*fieldpath.Set{ + "apinet.api.onmetal.de/v1alpha1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), + } +} + +func (nodeStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newNode := obj.(*core.Node) + oldNode := old.(*core.Node) + newNode.Spec = oldNode.Spec +} + +func (nodeStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newNode := obj.(*core.Node) + oldNode := old.(*core.Node) + return validation.ValidateNodeStatusUpdate(newNode, oldNode) +} + +func (nodeStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old runtime.Object) []string { + return nil +} diff --git a/internal/registry/node/tableconvertor.go b/internal/registry/node/tableconvertor.go new file mode 100644 index 00000000..428b4ce1 --- /dev/null +++ b/internal/registry/node/tableconvertor.go @@ -0,0 +1,67 @@ +// Copyright 2022 OnMetal 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 node + +import ( + "context" + + "github.com/onmetal/onmetal-api-net/internal/apis/core" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/meta/table" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type convertor struct{} + +var ( + objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() + + headers = []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, + {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, + } +) + +func newTableConvertor() *convertor { + return &convertor{} +} + +func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { + tab := &metav1.Table{ + ColumnDefinitions: headers, + } + + if m, err := meta.ListAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + tab.Continue = m.GetContinue() + } else { + if m, err := meta.CommonAccessor(obj); err == nil { + tab.ResourceVersion = m.GetResourceVersion() + } + } + + var err error + tab.Rows, err = table.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) (cells []interface{}, err error) { + node := obj.(*core.Node) + _ = node + + cells = append(cells, name) + cells = append(cells, age) + + return cells, nil + }) + return tab, err +} diff --git a/metalnetlet/client/client.go b/metalnetlet/client/client.go new file mode 100644 index 00000000..054a349c --- /dev/null +++ b/metalnetlet/client/client.go @@ -0,0 +1,60 @@ +// Copyright 2023 OnMetal 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 client + +import ( + "context" + "fmt" + + "github.com/onmetal/controller-utils/metautils" + "k8s.io/apimachinery/pkg/api/meta" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func DeleteAllOfAndAnyExists(ctx context.Context, c client.Client, obj client.Object, opts ...client.DeleteAllOfOption) (bool, error) { + o := &client.DeleteAllOfOptions{} + o.ApplyOptions(opts) + + if err := c.DeleteAllOf(ctx, obj, o); err != nil { + return false, err + } + + return AnyExists(ctx, c, obj, o) +} + +func AnyExists(ctx context.Context, c client.Client, obj client.Object, opts ...client.ListOption) (bool, error) { + _, list, err := metautils.NewListForObject(c.Scheme(), obj) + if err != nil { + return false, fmt.Errorf("error creating new list for object: %w", err) + } + + o := &client.ListOptions{} + o.ApplyOptions(opts) + o.Limit = 1 + + for { + if err := c.List(ctx, list, o); err != nil { + return false, err + } + if meta.LenList(list) > 0 { + // If we see at least one element, something still exists. + return true, nil + } + if o.Continue == "" { + // If we cannot continue doing List requests, return false (nothing exists) + return false, nil + } + } +} diff --git a/metalnetlet/client/config/getter.go b/metalnetlet/client/config/getter.go index 029d4bb4..49503872 100644 --- a/metalnetlet/client/config/getter.go +++ b/metalnetlet/client/config/getter.go @@ -19,7 +19,7 @@ import ( "crypto/x509/pkix" "os" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" + onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" utilcertificate "github.com/onmetal/onmetal-api/utils/certificate" "github.com/onmetal/onmetal-api/utils/client/config" certificatesv1 "k8s.io/api/certificates/v1" diff --git a/metalnetlet/client/sourceaware.go b/metalnetlet/client/sourceaware.go new file mode 100644 index 00000000..a3e7603a --- /dev/null +++ b/metalnetlet/client/sourceaware.go @@ -0,0 +1,58 @@ +// Copyright 2023 OnMetal 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 client + +import ( + utilapi "github.com/onmetal/onmetal-api-net/utils/api" + utilclient "github.com/onmetal/onmetal-api-net/utils/client" +) + +var ( + SourceAwareSystem = utilclient.NewSourceAwareSystem(utilapi.PrefixSourceAwareSystem("metalnetlet.api.onmetal.de/")) + + SourceLabelKeysE = SourceAwareSystem.SourceLabelKeysE + + SourceLabelKeys = SourceAwareSystem.SourceLabelKeys + + SourceLabelsE = SourceAwareSystem.SourceLabelsE + + SourceLabels = SourceAwareSystem.SourceLabels + + MatchingSourceLabelsE = SourceAwareSystem.MatchingSourceLabelsE + + MatchingSourceLabels = SourceAwareSystem.MatchingSourceLabels + + HasSourceLabelsE = SourceAwareSystem.HasSourceLabelsE + + HasSourceLabels = SourceAwareSystem.HasSourceLabels + + SourceKeyLabelsE = SourceAwareSystem.SourceKeyLabelsE + + SourceKeyLabels = SourceAwareSystem.SourceKeyLabels + + MatchingSourceKeyLabelsE = SourceAwareSystem.MatchingSourceKeyLabelsE + + MatchingSourceKeyLabels = SourceAwareSystem.MatchingSourceKeyLabels + + SourceObjectKeyFromObjectE = SourceAwareSystem.SourceObjectKeyFromObjectE + + SourceObjectKeyFromObject = SourceAwareSystem.SourceObjectKeyFromObject + + SourceObjectDataFromObjectE = SourceAwareSystem.SourceObjectDataFromObjectE + + SourceObjectDataFromObject = SourceAwareSystem.SourceObjectDataFromObject +) + +type SourceObjectData = utilclient.SourceObjectData diff --git a/metalnetlet/controllers/common.go b/metalnetlet/controllers/common.go new file mode 100644 index 00000000..fe80d124 --- /dev/null +++ b/metalnetlet/controllers/common.go @@ -0,0 +1,81 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + "strings" + + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/predicate" +) + +const ( + MetalnetFieldOwner = client.FieldOwner("metalnetlet.apinet.onmetal.de/controller-manager") + + PartitionFieldOwnerPrefix = "partition.metalnetlet.apinet.onmetal.de/" + + PartitionFinalizerPrefix = "partition.metalnetlet.apinet.onmetal.de/" +) + +func PartitionFieldOwner(partitionName string) client.FieldOwner { + return client.FieldOwner(PartitionFieldOwnerPrefix + partitionName) +} + +func PartitionFinalizer(partitionName string) string { + return PartitionFinalizerPrefix + partitionName +} + +func PartitionNodeName(partitionName, metalnetNodeName string) string { + return fmt.Sprintf("%s-%s", string(partitionName), metalnetNodeName) +} + +func ParseNodeName(partitionName, nodeName string) (string, error) { + prefix := partitionName + "-" + if !strings.HasPrefix(nodeName, prefix) { + return "", fmt.Errorf("node name %q does not belong to partition %s", nodeName, partitionName) + } + return strings.TrimPrefix(nodeName, prefix), nil +} + +func IsNodeOnPartitionPredicate(partitionName string) predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + node := obj.(*v1alpha1.Node) + _, err := ParseNodeName(partitionName, node.Name) + return err == nil + }) +} + +func GetMetalnetNode(ctx context.Context, partitionName string, metalnetClient client.Client, nodeName string) (*corev1.Node, error) { + metalnetNodeName, err := ParseNodeName(partitionName, nodeName) + if err != nil { + // Ignore any parsing error, what we know is that the node does not exist on our side. + return nil, nil + } + + metalnetNode := &corev1.Node{} + metalnetNodeKey := client.ObjectKey{Name: metalnetNodeName} + if err := metalnetClient.Get(ctx, metalnetNodeKey, metalnetNode); err != nil { + if !apierrors.IsNotFound(err) { + return nil, err + } + return nil, nil + } + return metalnetNode, nil +} diff --git a/metalnetlet/controllers/controllers_suite_test.go b/metalnetlet/controllers/controllers_suite_test.go index 4874e2f6..d3e576a2 100644 --- a/metalnetlet/controllers/controllers_suite_test.go +++ b/metalnetlet/controllers/controllers_suite_test.go @@ -18,12 +18,18 @@ package controllers import ( "context" + "net/netip" "path/filepath" "testing" "time" + "github.com/onmetal/controller-utils/buildutils" + "github.com/onmetal/controller-utils/modutils" metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + utilsenvtest "github.com/onmetal/onmetal-api/utils/envtest" + "github.com/onmetal/onmetal-api/utils/envtest/apiserver" + . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -41,18 +47,22 @@ import ( // These tests use Ginkgo (BDD-style Go testing framework). Refer to // http://onsi.github.io/ginkgo/ to learn more about Ginkgo. -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment +var ( + cfg *rest.Config + k8sClient client.Client + testEnv *envtest.Environment + testEnvExt *utilsenvtest.EnvironmentExtensions +) const ( pollingInterval = 50 * time.Millisecond eventuallyTimeout = 3 * time.Second consistentlyDuration = 1 * time.Second + apiServiceTimeout = 1 * time.Minute ) const ( - metalnetletName = "test-metalnetlet" + partitionName = "test-metalnetlet" ) func TestControllers(t *testing.T) { @@ -66,24 +76,31 @@ func TestControllers(t *testing.T) { RunSpecs(t, "Controller Suite") } +func PrefixV4() netip.Prefix { + return netip.MustParsePrefix("10.0.0.0/24") +} + var _ = BeforeSuite(func() { logf.SetLogger(GinkgoLogr) + var err error + By("bootstrapping test environment") testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{ - filepath.Join("..", "..", "config", "onmetal-api-net", "crd", "bases"), - filepath.Join("testdata", "metalnet-crds"), + filepath.Join(modutils.Dir("github.com/onmetal/metalnet", "config", "crd", "bases")), }, ErrorIfCRDPathMissing: true, } + testEnvExt = &utilsenvtest.EnvironmentExtensions{ + APIServiceDirectoryPaths: []string{filepath.Join("..", "..", "config", "apiserver", "apiservice", "bases")}, + ErrorIfAPIServicePathIsMissing: true, + } - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() + cfg, err = utilsenvtest.StartWithExtensions(testEnv, testEnvExt) Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - DeferCleanup(testEnv.Stop) + DeferCleanup(utilsenvtest.StopWithExtensions, testEnv, testEnvExt) Expect(v1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) Expect(metalnetv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed()) @@ -96,44 +113,88 @@ var _ = BeforeSuite(func() { SetClient(k8sClient) - k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - Host: "127.0.0.1", - MetricsBindAddress: "0", + apiSrv, err := apiserver.New(cfg, apiserver.Options{ + MainPath: "github.com/onmetal/onmetal-api-net/cmd/apiserver", + BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod}, + ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()}, + Host: testEnvExt.APIServiceInstallOptions.LocalServingHost, + Port: testEnvExt.APIServiceInstallOptions.LocalServingPort, + CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir, + Args: apiserver.ProcessArgs{ + "public-prefix": []string{PrefixV4().String()}, + }, }) - Expect(err).ToNot(HaveOccurred()) - - // register reconciler here - Expect((&NetworkReconciler{ - Client: k8sManager.GetClient(), - MetalnetCluster: k8sManager, - Name: metalnetletName, - }).SetupWithManager(k8sManager)).To(Succeed()) - - mgrCtx, cancel := context.WithCancel(context.Background()) - DeferCleanup(cancel) - go func() { - defer GinkgoRecover() - Expect(k8sManager.Start(mgrCtx)).To(Succeed(), "failed to start manager") - }() -}) + Expect(err).NotTo(HaveOccurred()) + + Expect(apiSrv.Start()).To(Succeed()) + DeferCleanup(apiSrv.Stop) -func SetupTest() *corev1.Namespace { - ns := &corev1.Namespace{} + Expect(utilsenvtest.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed()) +}) +func SetupTest(metalnetNs *corev1.Namespace) { BeforeEach(func(ctx SpecContext) { + k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ + Scheme: scheme.Scheme, + Host: "127.0.0.1", + MetricsBindAddress: "0", + }) + Expect(err).ToNot(HaveOccurred()) + + // register reconciler here + Expect((&NetworkReconciler{ + Client: k8sManager.GetClient(), + MetalnetClient: k8sManager.GetClient(), + PartitionName: partitionName, + MetalnetNamespace: metalnetNs.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + + Expect((&MetalnetNodeReconciler{ + Client: k8sManager.GetClient(), + MetalnetClient: k8sManager.GetClient(), + PartitionName: partitionName, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + + Expect((&NetworkInterfaceReconciler{ + Client: k8sManager.GetClient(), + MetalnetClient: k8sManager.GetClient(), + PartitionName: partitionName, + MetalnetNamespace: metalnetNs.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + + Expect((&InstanceReconciler{ + Client: k8sManager.GetClient(), + MetalnetClient: k8sManager.GetClient(), + PartitionName: partitionName, + MetalnetNamespace: metalnetNs.Name, + }).SetupWithManager(k8sManager, k8sManager.GetCache())).To(Succeed()) + + mgrCtx, cancel := context.WithCancel(context.Background()) + DeferCleanup(cancel) + go func() { + defer GinkgoRecover() + Expect(k8sManager.Start(mgrCtx)).To(Succeed(), "failed to start manager") + }() + }) +} - *ns = corev1.Namespace{ +func SetupMetalnetNode() *corev1.Node { + return SetupObjectStruct[*corev1.Node](&k8sClient, func(node *corev1.Node) { + *node = corev1.Node{ ObjectMeta: metav1.ObjectMeta{ - GenerateName: "testns-", + GenerateName: "node-", }, } - Expect(k8sClient.Create(ctx, ns)).To(Succeed(), "failed to create test namespace") - - DeferCleanup(func(ctx context.Context) { - Expect(k8sClient.Delete(ctx, ns)).To(Succeed(), "failed to delete test namespace") - }) }) +} - return ns +func SetupNetwork(ns *corev1.Namespace) *v1alpha1.Network { + return SetupObjectStruct[*v1alpha1.Network](&k8sClient, func(network *v1alpha1.Network) { + *network = v1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "network-", + }, + } + }) } diff --git a/metalnetlet/controllers/conversion.go b/metalnetlet/controllers/conversion.go new file mode 100644 index 00000000..635832e8 --- /dev/null +++ b/metalnetlet/controllers/conversion.go @@ -0,0 +1,129 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "fmt" + "net/netip" + + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + "github.com/onmetal/onmetal-api/utils/generic" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + corev1 "k8s.io/api/core/v1" +) + +func ipPrefixToMetalnetPrefix(p net.IPPrefix) metalnetv1alpha1.IPPrefix { + return metalnetv1alpha1.IPPrefix{Prefix: p.Prefix} +} + +func ipPrefixesToMetalnetPrefixes(ps []net.IPPrefix) []metalnetv1alpha1.IPPrefix { + return utilslices.Map(ps, ipPrefixToMetalnetPrefix) +} + +func ipToMetalnetIP(ip net.IP) metalnetv1alpha1.IP { + return metalnetv1alpha1.IP{Addr: ip.Addr} +} + +func ipsToMetalnetIPs(ips []net.IP) []metalnetv1alpha1.IP { + return utilslices.Map(ips, ipToMetalnetIP) +} + +func ipToMetalnetIPPrefix(ip net.IP) metalnetv1alpha1.IPPrefix { + return metalnetv1alpha1.IPPrefix{Prefix: netip.PrefixFrom(ip.Addr, ip.BitLen())} +} + +func ipsToMetalnetIPPrefixes(ips []net.IP) []metalnetv1alpha1.IPPrefix { + return utilslices.Map(ips, ipToMetalnetIPPrefix) +} + +func ipsIPFamilies(ips []net.IP) []corev1.IPFamily { + return utilslices.Map(ips, net.IP.Family) +} + +func metalnetIPToIP(ip metalnetv1alpha1.IP) net.IP { + return net.IP{Addr: ip.Addr} +} + +func metalnetIPsToIPs(ips []metalnetv1alpha1.IP) []net.IP { + return utilslices.Map(ips, metalnetIPToIP) +} + +func metalnetIPPrefixToIPPrefix(prefix metalnetv1alpha1.IPPrefix) net.IPPrefix { + return net.IPPrefix{Prefix: prefix.Prefix} +} + +func metalnetIPPrefixesToIPPrefixes(prefixes []metalnetv1alpha1.IPPrefix) []net.IPPrefix { + return utilslices.Map(prefixes, metalnetIPPrefixToIPPrefix) +} + +func loadBalancerTypeToMetalnetLoadBalancerType(loadBalancerType v1alpha1.LoadBalancerType) (metalnetv1alpha1.LoadBalancerType, error) { + switch loadBalancerType { + case v1alpha1.LoadBalancerTypePublic: + return metalnetv1alpha1.LoadBalancerTypePublic, nil + case v1alpha1.LoadBalancerTypeInternal: + return metalnetv1alpha1.LoadBalancerTypeInternal, nil + default: + return "", fmt.Errorf("unknown load balancer type %q", loadBalancerType) + } +} + +func loadBalancerPortToMetalnetLoadBalancerPort(port v1alpha1.LoadBalancerPort) metalnetv1alpha1.LBPort { + protocol := generic.Deref(port.Protocol, corev1.ProtocolTCP) + + return metalnetv1alpha1.LBPort{ + Protocol: string(protocol), + Port: port.Port, + } +} + +func loadBalancerPortsToMetalnetLoadBalancerPorts(ports []v1alpha1.LoadBalancerPort) []metalnetv1alpha1.LBPort { + return utilslices.Map(ports, loadBalancerPortToMetalnetLoadBalancerPort) +} + +// workaroundMetalnetNoIPv6VirtualIPSupportIPsToIP works around the missing public IPv6 support in metalnet +// by propagating only IPv4 addresses to metalnet. +// TODO: Remove this as soon as https://github.com/onmetal/metalnet/issues/53 is resolved. +func workaroundMetalnetNoIPv6VirtualIPSupportIPsToIP(metalnetVirtualIPs []metalnetv1alpha1.IP) *metalnetv1alpha1.IP { + for _, metalnetVirtualIP := range metalnetVirtualIPs { + if metalnetVirtualIP.Is4() { + ip := metalnetVirtualIP + return &ip + } + } + return nil +} + +// workaroundMetalnetNoIPv6IPToIPs works around the missing public IPv6 support in metalnet by +// making a slice of the single virtual IP. +func workaroundMetalnetNoIPv6IPToIPs(metalnetVirtualIP *metalnetv1alpha1.IP) []metalnetv1alpha1.IP { + if metalnetVirtualIP.IsZero() { + return nil + } + return []metalnetv1alpha1.IP{*metalnetVirtualIP} +} + +// workaroundMetalnetNoIPv6NATDetailsToNATDetailsPointer works around the missing NAT IPv6 support in metalnet by +// returning only the IPv4 NAT details. +func workaroundMetalnetNoIPv6NATDetailsToNATDetailsPointer(natDetails []metalnetv1alpha1.NATDetails) *metalnetv1alpha1.NATDetails { + for _, natDetails := range natDetails { + if natDetails.IP.Is4() { + details := natDetails + return &details + } + } + return nil +} diff --git a/metalnetlet/controllers/instance_controller.go b/metalnetlet/controllers/instance_controller.go new file mode 100644 index 00000000..7a382ecb --- /dev/null +++ b/metalnetlet/controllers/instance_controller.go @@ -0,0 +1,348 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "encoding/binary" + "errors" + "fmt" + "hash/fnv" + + "github.com/go-logr/logr" + "github.com/onmetal/controller-utils/clientutils" + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + metalnetletclient "github.com/onmetal/onmetal-api-net/metalnetlet/client" + utilhandler "github.com/onmetal/onmetal-api-net/metalnetlet/handler" + "github.com/onmetal/onmetal-api/utils/generic" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/apimachinery/pkg/util/sets" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +type InstanceReconciler struct { + client.Client + MetalnetClient client.Client + + PartitionName string + + MetalnetNamespace string +} + +//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=instances,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=instances/finalizers,verbs=update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=instances/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networks,verbs=get;list;watch + +//+cluster=metalnet:kubebuilder:rbac:groups=networking.metalnet.onmetal.de,resources=loadbalancers,verbs=get;list;watch;create;update;patch;delete;deletecollection + +func (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + instance := &v1alpha1.Instance{} + if err := r.Get(ctx, req.NamespacedName, instance); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, err + } + + log.V(1).Info("Deleting any leftover metalnet load balancers") + anyExists, err := r.deleteMetalnetLoadBalancersByLoadBalancerInstanceKeyAndAnyExists(ctx, req.NamespacedName) + if err != nil { + return ctrl.Result{}, err + } + if anyExists { + log.V(1).Info("Some metalnet load balancers still exist, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("Any potential leftover metalnet load balancer is gone") + return ctrl.Result{}, nil + } + + return r.reconcileExists(ctx, log, instance) +} + +func (r *InstanceReconciler) reconcileExists(ctx context.Context, log logr.Logger, loadBalancerInstance *v1alpha1.Instance) (ctrl.Result, error) { + if !loadBalancerInstance.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, loadBalancerInstance) + } + return r.reconcile(ctx, log, loadBalancerInstance) +} + +func (r *InstanceReconciler) deleteMetalnetLoadBalancersByLoadBalancerInstanceKeyAndAnyExists(ctx context.Context, key client.ObjectKey) (bool, error) { + return metalnetletclient.DeleteAllOfAndAnyExists(ctx, r.MetalnetClient, &metalnetv1alpha1.LoadBalancer{}, + client.InNamespace(r.MetalnetNamespace), + metalnetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), key, &v1alpha1.Instance{}), + ) +} + +func (r *InstanceReconciler) deleteMetalnetLoadBalancersByLoadBalancerInstanceAndAnyExists(ctx context.Context, inst *v1alpha1.Instance) (bool, error) { + return metalnetletclient.DeleteAllOfAndAnyExists(ctx, r.MetalnetClient, &metalnetv1alpha1.LoadBalancer{}, + client.InNamespace(r.MetalnetNamespace), + metalnetletclient.MatchingSourceLabels(r.Scheme(), r.RESTMapper(), inst), + ) +} + +func (r *InstanceReconciler) delete(ctx context.Context, log logr.Logger, loadBalancerInstance *v1alpha1.Instance) (ctrl.Result, error) { + log.V(1).Info("Delete") + if !controllerutil.ContainsFinalizer(loadBalancerInstance, PartitionFinalizer(r.PartitionName)) { + log.V(1).Info("Finalizer not present, nothing to do") + return ctrl.Result{}, nil + } + log.V(1).Info("Finalizer present, doing cleanup") + anyExists, err := r.deleteMetalnetLoadBalancersByLoadBalancerInstanceAndAnyExists(ctx, loadBalancerInstance) + if err != nil { + return ctrl.Result{}, err + } + if anyExists { + log.V(1).Info("Some metalnet load balancers are still present, requeuing") + return ctrl.Result{Requeue: true}, nil + } + + log.V(1).Info("All metalnet load balancers gone, removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, loadBalancerInstance, PartitionFinalizer(r.PartitionName)); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + + log.V(1).Info("Deleted") + return ctrl.Result{}, nil +} + +func (r *InstanceReconciler) getMetalnetLoadBalancersForLoadBalancerInstance( + ctx context.Context, + loadBalancerInstance *v1alpha1.Instance, +) ([]metalnetv1alpha1.LoadBalancer, error) { + metalnetLoadBalancerList := &metalnetv1alpha1.LoadBalancerList{} + if err := r.MetalnetClient.List(ctx, metalnetLoadBalancerList, + client.InNamespace(r.MetalnetNamespace), + metalnetletclient.MatchingSourceLabels(r.Scheme(), r.RESTMapper(), loadBalancerInstance), + ); err != nil { + return nil, fmt.Errorf("error listing metalnet load balancer instances: %w", err) + } + return metalnetLoadBalancerList.Items, nil +} + +func (r *InstanceReconciler) manageMetalnetLoadBalancers( + ctx context.Context, + log logr.Logger, + inst *v1alpha1.Instance, + metalnetNodeName string, +) (bool, error) { + network := &v1alpha1.Network{} + networkKey := client.ObjectKey{Namespace: inst.Namespace, Name: inst.Spec.NetworkRef.Name} + if err := r.Get(ctx, networkKey, network); err != nil { + return false, client.IgnoreNotFound(err) + } + + metalnetLoadBalancerType, err := loadBalancerTypeToMetalnetLoadBalancerType(inst.Spec.LoadBalancerType) + if err != nil { + return false, err + } + + metalnetLoadBalancers, err := r.getMetalnetLoadBalancersForLoadBalancerInstance(ctx, inst) + if err != nil { + return false, err + } + + var ( + unsatisfiedIPs = sets.New(inst.Spec.IPs...) + errs []error + ) + for _, metalnetLoadBalancer := range metalnetLoadBalancers { + ip := metalnetIPToIP(metalnetLoadBalancer.Spec.IP) + if unsatisfiedIPs.Has(ip) { + unsatisfiedIPs.Delete(ip) + continue + } + + if err := r.Delete(ctx, &metalnetLoadBalancer); client.IgnoreNotFound(err) != nil { + errs = append(errs, err) + continue + } + } + + var bumpCollisionCount bool + for ip := range unsatisfiedIPs { + metalnetLoadBalancerHash := computeMetalnetLoadBalancerHash(ip, inst.Status.CollisionCount) + metalnetLoadBalancerSpec := metalnetv1alpha1.LoadBalancerSpec{ + NetworkRef: corev1.LocalObjectReference{Name: string(network.UID)}, + LBtype: metalnetLoadBalancerType, + IPFamily: ip.Family(), + IP: ipToMetalnetIP(ip), + Ports: loadBalancerPortsToMetalnetLoadBalancerPorts(inst.Spec.LoadBalancerPorts), + NodeName: &metalnetNodeName, + } + metalnetLoadBalancerName := string(inst.UID) + "-" + metalnetLoadBalancerHash + metalnetLoadBalancer := &metalnetv1alpha1.LoadBalancer{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.MetalnetNamespace, + Name: metalnetLoadBalancerName, + Labels: metalnetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), inst), + }, + Spec: metalnetLoadBalancerSpec, + } + createMetalnetLoadBalancer := metalnetLoadBalancer.DeepCopy() + if err := r.Create(ctx, metalnetLoadBalancer); err != nil { + if !apierrors.IsAlreadyExists(err) { + errs = append(errs, err) + continue + } + + // We may end up hitting this due to a slow cache or a fast resync of the load balancer instance. + metalnetLoadBalancerKey := client.ObjectKey{Namespace: r.MetalnetNamespace, Name: metalnetLoadBalancerName} + if err := r.Get(ctx, metalnetLoadBalancerKey, metalnetLoadBalancer); err != nil { + errs = append(errs, err) + continue + } + + if EqualMetalnetLoadBalancers(createMetalnetLoadBalancer, metalnetLoadBalancer) { + continue + } + + // Issue collision count bump and return original already exists error. + bumpCollisionCount = true + errs = append(errs, err) + } + } + if bumpCollisionCount { + if err := r.bumpLoadBalancerInstanceCollisionCount(ctx, inst); err != nil { + log.Error(err, "Error bumping collision count") + } else { + log.V(1).Info("Bumped collision count") + } + } + return true, errors.Join(errs...) +} + +func EqualMetalnetLoadBalancers(inst1, inst2 *metalnetv1alpha1.LoadBalancer) bool { + return inst1.Spec.IP == inst2.Spec.IP && + inst1.Spec.IPFamily == inst2.Spec.IPFamily && + inst1.Spec.NetworkRef == inst2.Spec.NetworkRef && + inst1.Spec.LBtype == inst2.Spec.LBtype && + slices.Equal(inst1.Spec.Ports, inst2.Spec.Ports) +} + +func (r *InstanceReconciler) bumpLoadBalancerInstanceCollisionCount(ctx context.Context, loadBalancerInstance *v1alpha1.Instance) error { + oldCollisionCount := generic.Deref(loadBalancerInstance.Status.CollisionCount, 0) + base := loadBalancerInstance.DeepCopy() + loadBalancerInstance.Status.CollisionCount = generic.Pointer(oldCollisionCount + 1) + return r.Status().Patch(ctx, loadBalancerInstance, client.MergeFrom(base)) +} + +func computeMetalnetLoadBalancerHash(ip net.IP, collisionCount *int32) string { + h := fnv.New32a() + + _, _ = h.Write(ip.AsSlice()) + + // Add collisionCount in the hash if it exists + if collisionCount != nil { + collisionCountBytes := make([]byte, 8) + binary.LittleEndian.PutUint32(collisionCountBytes, uint32(*collisionCount)) + _, _ = h.Write(collisionCountBytes) + } + + return rand.SafeEncodeString(fmt.Sprint(h.Sum32())) +} + +func (r *InstanceReconciler) reconcile(ctx context.Context, log logr.Logger, loadBalancerInstance *v1alpha1.Instance) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + metalnetNode, err := GetMetalnetNode(ctx, r.PartitionName, r.MetalnetClient, loadBalancerInstance.Spec.NodeRef.Name) + if err != nil { + return ctrl.Result{}, err + } + if metalnetNode == nil || !metalnetNode.DeletionTimestamp.IsZero() { + if !controllerutil.ContainsFinalizer(loadBalancerInstance, PartitionFinalizer(r.PartitionName)) { + log.V(1).Info("Finalizer not present and metalnet node not found / deleting, nothing to do") + return ctrl.Result{}, nil + } + + anyExists, err := r.deleteMetalnetLoadBalancersByLoadBalancerInstanceAndAnyExists(ctx, loadBalancerInstance) + if err != nil { + return ctrl.Result{}, err + } + if anyExists { + log.V(1).Info("Not yet all metalnet load balancers gone, requeueing") + return ctrl.Result{Requeue: true}, nil + } + + log.V(1).Info("All metalnet load balancers gone, removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, loadBalancerInstance, PartitionFinalizer(r.PartitionName)); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + log.V(1).Info("Removed finalizer") + return ctrl.Result{}, nil + } + + log.V(1).Info("Metalnet node present and not deleting, ensuring finalizer") + modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, loadBalancerInstance, PartitionFinalizer(r.PartitionName)) + if err != nil { + return ctrl.Result{}, err + } + if modified { + log.V(1).Info("Added finalizer, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("Finalizer present") + + ok, err := r.manageMetalnetLoadBalancers(ctx, log, loadBalancerInstance, metalnetNode.Name) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error managing metalnet load balancers: %w", err) + } + if !ok { + log.V(1).Info("Not all load balancer instance dependencies are ready") + return ctrl.Result{}, nil + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *InstanceReconciler) isPartitionLoadBalancerInstance() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + loadBalancerInstance := obj.(*v1alpha1.Instance) + nodeRef := loadBalancerInstance.Spec.NodeRef + if nodeRef == nil { + return false + } + + _, err := ParseNodeName(r.PartitionName, nodeRef.Name) + return err == nil + }) +} + +func (r *InstanceReconciler) SetupWithManager(mgr ctrl.Manager, metalnetCache cache.Cache) error { + return ctrl.NewControllerManagedBy(mgr). + For( + &v1alpha1.Instance{}, + builder.WithPredicates(r.isPartitionLoadBalancerInstance()), + ). + WatchesRawSource( + source.Kind(metalnetCache, &metalnetv1alpha1.LoadBalancer{}), + utilhandler.EnqueueRequestForSource(r.Scheme(), r.RESTMapper(), &v1alpha1.LoadBalancer{}), + ). + Complete(r) +} diff --git a/metalnetlet/controllers/instance_controller_test.go b/metalnetlet/controllers/instance_controller_test.go new file mode 100644 index 00000000..2cf816bd --- /dev/null +++ b/metalnetlet/controllers/instance_controller_test.go @@ -0,0 +1,66 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("LoadBalancerInstanceController", func() { + ns := SetupNamespace(&k8sClient) + metalnetNs := SetupNamespace(&k8sClient) + SetupTest(metalnetNs) + + metalnetNode := SetupMetalnetNode() + network := SetupNetwork(ns) + + It("should reconcile the metalnet load balancers for the load balancer instance", func(ctx SpecContext) { + By("creating a load balancer instance") + inst := &v1alpha1.Instance{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "lb-", + }, + Spec: v1alpha1.InstanceSpec{ + Type: v1alpha1.InstanceTypeLoadBalancer, + LoadBalancerType: v1alpha1.LoadBalancerTypePublic, + NetworkRef: corev1.LocalObjectReference{Name: network.Name}, + IPs: []net.IP{ + net.MustParseIP("10.0.0.1"), + net.MustParseIP("10.0.0.2"), + }, + NodeRef: &corev1.LocalObjectReference{ + Name: PartitionNodeName(partitionName, metalnetNode.Name), + }, + }, + } + Expect(k8sClient.Create(ctx, inst)).To(Succeed()) + + By("waiting for the metalnet load balancers to appear") + metalnetLoadBalancerList := &metalnetv1alpha1.LoadBalancerList{} + Eventually(ObjectList(metalnetLoadBalancerList)).Should(HaveField("Items", ConsistOf( + HaveField("Spec.IP", metalnetv1alpha1.MustParseIP("10.0.0.1")), + HaveField("Spec.IP", metalnetv1alpha1.MustParseIP("10.0.0.2")), + ))) + }) +}) diff --git a/metalnetlet/controllers/metalnetnode_controller.go b/metalnetlet/controllers/metalnetnode_controller.go new file mode 100644 index 00000000..d2050da7 --- /dev/null +++ b/metalnetlet/controllers/metalnetnode_controller.go @@ -0,0 +1,206 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/controller-utils/clientutils" + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +const metalnetNodeFinalizer = "apinet.api.onmetal.de/node" + +type MetalnetNodeReconciler struct { + client.Client + MetalnetClient client.Client + PartitionName string +} + +//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nodes,verbs=get;list;watch;update;patch;create;delete +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nodes/finalizers,verbs=update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nodes/status,verbs=get;update;patch + +//+cluster=metalnet:kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch + +// Reconcile ensures that the node is in the expected state. +func (r *MetalnetNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + + metalnetNode := &corev1.Node{} + if err := r.MetalnetClient.Get(ctx, req.NamespacedName, metalnetNode); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error getting metalnet node: %w", err) + } + + log.V(1).Info("Metalnet node not found, deleting any corresponding node") + node := &v1alpha1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: PartitionNodeName(r.PartitionName, metalnetNode.Name), + }, + } + if err := r.Delete(ctx, node); client.IgnoreNotFound(err) != nil { + return ctrl.Result{}, fmt.Errorf("error deleting node: %w", err) + } + log.V(1).Info("Deleted corresponding node") + return ctrl.Result{}, nil + } + + return r.reconcileExists(ctx, log, metalnetNode) +} + +func (r *MetalnetNodeReconciler) reconcileExists(ctx context.Context, log logr.Logger, metalnetNode *corev1.Node) (ctrl.Result, error) { + if !metalnetNode.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, metalnetNode) + } + return r.reconcile(ctx, log, metalnetNode) +} + +func (r *MetalnetNodeReconciler) delete(ctx context.Context, log logr.Logger, metalnetNode *corev1.Node) (ctrl.Result, error) { + log.V(1).Info("Delete") + + if !controllerutil.ContainsFinalizer(metalnetNode, metalnetNodeFinalizer) { + log.V(1).Info("No finalizer present, nothing to do") + return ctrl.Result{}, nil + } + + log.V(1).Info("Deleting any corresponding node") + node := &v1alpha1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: PartitionNodeName(r.PartitionName, metalnetNode.Name), + }, + } + if err := r.Delete(ctx, node); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error deleting node: %w", err) + } + + log.V(1).Info("Any corresponding node is gone, removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, metalnetNode, metalnetNodeFinalizer); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + log.V(1).Info("Deleted") + return ctrl.Result{}, nil + } + log.V(1).Info("Issued node deletion, requeuing") + return ctrl.Result{Requeue: true}, nil +} + +func (r *MetalnetNodeReconciler) reconcile(ctx context.Context, log logr.Logger, metalnetNode *corev1.Node) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + log.V(1).Info("Ensuring finalizer") + modified, err := clientutils.PatchEnsureFinalizer(ctx, r.MetalnetClient, metalnetNode, metalnetNodeFinalizer) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error ensuring finalizer: %w", err) + } + if modified { + log.V(1).Info("Added finalizer, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("Finalizer is present") + + log.V(1).Info("Applying node") + node := &v1alpha1.Node{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "Node", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: PartitionNodeName(r.PartitionName, metalnetNode.Name), + }, + } + if err := r.Patch(ctx, node, client.Apply, PartitionFieldOwner(r.PartitionName), client.ForceOwnership); err != nil { + return ctrl.Result{}, fmt.Errorf("error applying node: %w", err) + } + log.V(1).Info("Applied node") + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *MetalnetNodeReconciler) enqueueByMetalnetNode() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + node := obj.(*corev1.Node) + return []ctrl.Request{{NamespacedName: client.ObjectKey{Name: node.Name}}} + }) +} + +func (r *MetalnetNodeReconciler) logConstructor(mgr ctrl.Manager) func(req *ctrl.Request) logr.Logger { + log := mgr.GetLogger().WithValues( + "controller", "node", + "controllerGroup", metalnetv1alpha1.GroupVersion.Group, + "controllerKind", "Node", + ) + + return func(req *ctrl.Request) logr.Logger { + log := log + if req != nil { + nodeName := PartitionNodeName(r.PartitionName, req.Name) + log = log.WithValues( + "Node", req.Name, + "APINetNode", klog.KRef("", nodeName), + "namespace", "", "name", req.Name, + ) + } + return log + } +} + +func (r *MetalnetNodeReconciler) enqueueByNode() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + node := obj.(*v1alpha1.Node) + log := ctrl.LoggerFrom(ctx) + + metalnetNodeName, err := ParseNodeName(r.PartitionName, node.Name) + if err != nil { + log.Error(err, "Error parsing node name: %w", err) + return nil + } + + return []ctrl.Request{{NamespacedName: client.ObjectKey{Name: metalnetNodeName}}} + }) +} + +func (r *MetalnetNodeReconciler) SetupWithManager(mgr ctrl.Manager, metalnetCache cache.Cache) error { + return ctrl.NewControllerManagedBy(mgr). + Named("metalnetnode"). + WithLogConstructor(r.logConstructor(mgr)). + WatchesRawSource( + source.Kind(metalnetCache, &corev1.Node{}), + r.enqueueByMetalnetNode(), + ). + Watches( + &v1alpha1.Node{}, + r.enqueueByNode(), + builder.WithPredicates(IsNodeOnPartitionPredicate(r.PartitionName)), + ). + Complete(r) +} diff --git a/metalnetlet/controllers/metalnetnode_controller_test.go b/metalnetlet/controllers/metalnetnode_controller_test.go new file mode 100644 index 00000000..18ac6558 --- /dev/null +++ b/metalnetlet/controllers/metalnetnode_controller_test.go @@ -0,0 +1,51 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("MetalnetNodeController", func() { + metalnetNs := SetupNamespace(&k8sClient) + SetupTest(metalnetNs) + + metalnetNode := SetupMetalnetNode() + + It("should reconcile the metalnet nodes with the nodes", func(ctx SpecContext) { + By("waiting for the metalnet node to have a finalizer") + Eventually(Object(metalnetNode)).Should(HaveField("Finalizers", []string{metalnetNodeFinalizer})) + + By("waiting for the corresponding node to appear") + node := &v1alpha1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: PartitionNodeName(partitionName, metalnetNode.Name), + }, + } + Eventually(Get(node)).Should(Succeed()) + + By("deleting the metalnet node") + Expect(k8sClient.Delete(ctx, metalnetNode)).To(Succeed()) + + By("waiting for the node to be gone") + Eventually(Get(node)).Should(Satisfy(apierrors.IsNotFound)) + }) +}) diff --git a/metalnetlet/controllers/network_controller.go b/metalnetlet/controllers/network_controller.go index 01844dd4..3ac7822e 100644 --- a/metalnetlet/controllers/network_controller.go +++ b/metalnetlet/controllers/network_controller.go @@ -21,49 +21,33 @@ import ( "github.com/go-logr/logr" "github.com/onmetal/controller-utils/clientutils" metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/apiutils" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + metalnetletclient "github.com/onmetal/onmetal-api-net/metalnetlet/client" + metalnetlethandler "github.com/onmetal/onmetal-api-net/metalnetlet/handler" + "github.com/onmetal/onmetal-api-net/networkid" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" ) -const ( - metalnetNetworkFieldOwner = client.FieldOwner("metalnetlet.apinet.onmetal.de/field-owner") - networkNamespaceLabel = "metalnetlet.apinet.onmetal.de/network-namespace" - networkNameLabel = "metalnetlet.apinet.onmetal.de/network-name" - networkUIDLabel = "metalnet.apinet.onmetal.de/network-uid" -) +type NetworkReconciler struct { + client.Client + MetalnetClient client.Client -func finalizer(name string) string { - return fmt.Sprintf("%s.metalnetlet.apinet.onmetal.de/network", name) -} + PartitionName string -func getNetworkVNI(network *v1alpha1.Network) (int32, bool) { - if !apiutils.IsNetworkAllocated(network) { - return 0, false - } - vni := network.Spec.VNI - if vni == nil { - return 0, false - } - return *vni, true + MetalnetNamespace string } -type NetworkReconciler struct { - client.Client - MetalnetCluster cluster.Cluster - Name string -} +//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networks,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networks/finalizers,verbs=update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=networks,verbs=get;list;watch +//+cluster=metalnet:kubebuilder:rbac:groups=networking.metalnet.onmetal.de,resources=networks,verbs=get;list;watch;create;update;patch;delete;deletecollection func (r *NetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) @@ -82,11 +66,9 @@ func (r *NetworkReconciler) deleteGone(ctx context.Context, log logr.Logger, net log.V(1).Info("Delete gone") log.V(1).Info("Deleting all metalnet networks that match the network label") - if err := r.MetalnetCluster.GetClient().DeleteAllOf(ctx, &metalnetv1alpha1.Network{}, - client.MatchingLabels{ - networkNamespaceLabel: networkKey.Namespace, - networkNameLabel: networkKey.Name, - }, + if err := r.MetalnetClient.DeleteAllOf(ctx, &metalnetv1alpha1.Network{}, + client.InNamespace(r.MetalnetNamespace), + metalnetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), networkKey, &v1alpha1.Network{}), ); err != nil { return ctrl.Result{}, fmt.Errorf("error deleting metalnet networks matching network label: %w", err) } @@ -105,22 +87,21 @@ func (r *NetworkReconciler) reconcileExists(ctx context.Context, log logr.Logger func (r *NetworkReconciler) delete(ctx context.Context, log logr.Logger, network *v1alpha1.Network) (ctrl.Result, error) { log.V(1).Info("Delete") - if !controllerutil.ContainsFinalizer(network, finalizer(r.Name)) { + if !controllerutil.ContainsFinalizer(network, PartitionFinalizer(r.PartitionName)) { log.V(1).Info("No finalizer present, nothing to do") return ctrl.Result{}, nil } log.V(1).Info("Finalizer present, cleaning up") - vni := *network.Spec.VNI - log.V(1).Info("Deleting metalnet network if present") metalnetNetwork := &metalnetv1alpha1.Network{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("network-%d", vni), + Namespace: r.MetalnetNamespace, + Name: string(network.UID), }, } - err := r.MetalnetCluster.GetClient().Delete(ctx, metalnetNetwork) + err := r.MetalnetClient.Delete(ctx, metalnetNetwork) if err != nil && !apierrors.IsNotFound(err) { return ctrl.Result{}, fmt.Errorf("error deleting metalnet network: %w", err) } @@ -130,7 +111,7 @@ func (r *NetworkReconciler) delete(ctx context.Context, log logr.Logger, network } log.V(1).Info("Metalnet network is gone, removing finalizer") - if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, network, finalizer(r.Name)); err != nil { + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, network, PartitionFinalizer(r.PartitionName)); err != nil { return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) } log.V(1).Info("Removed finalizer") @@ -142,14 +123,14 @@ func (r *NetworkReconciler) delete(ctx context.Context, log logr.Logger, network func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, network *v1alpha1.Network) (ctrl.Result, error) { log.V(1).Info("Reconcile") - vni, ok := getNetworkVNI(network) - if !ok { - log.V(1).Info("Network is not yet allocated") + vni, err := networkid.ParseVNI(network.Spec.ID) + if err != nil { + log.Error(err, "Network has invalid ID", "ID", network.Spec.ID) return ctrl.Result{}, nil } log.V(1).Info("Ensuring finalizer") - modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, network, finalizer(r.Name)) + modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, network, PartitionFinalizer(r.PartitionName)) if err != nil { return ctrl.Result{}, fmt.Errorf("error ensuring finalizer: %w", err) } @@ -166,18 +147,15 @@ func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, netw Kind: "Network", }, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("network-%d", vni), - Labels: map[string]string{ - networkNamespaceLabel: network.Namespace, - networkNameLabel: network.Name, - networkUIDLabel: string(network.UID), - }, + Namespace: r.MetalnetNamespace, + Name: string(network.UID), + Labels: metalnetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), network), }, Spec: metalnetv1alpha1.NetworkSpec{ ID: vni, }, } - if err := r.MetalnetCluster.GetClient().Patch(ctx, metalnetNetwork, client.Apply, metalnetNetworkFieldOwner); err != nil { + if err := r.MetalnetClient.Patch(ctx, metalnetNetwork, client.Apply, MetalnetFieldOwner, client.ForceOwnership); err != nil { return ctrl.Result{}, fmt.Errorf("error applying network: %w", err) } log.V(1).Info("Applied metalnet network") @@ -186,39 +164,14 @@ func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, netw return ctrl.Result{}, nil } -func (r *NetworkReconciler) enqueueNetworkUsingNetworkLabels() handler.EventHandler { - return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { - metalnetNetwork := obj.(*metalnetv1alpha1.Network) - networkNamespace, networkName := metalnetNetwork.Labels[networkNamespaceLabel], metalnetNetwork.Labels[networkNameLabel] - if networkNamespace == "" || networkName == "" { - return nil - } - return []ctrl.Request{ - { - NamespacedName: client.ObjectKey{ - Namespace: networkNamespace, - Name: networkName, - }, - }, - } - }) -} - -var networkHasVNI = predicate.NewPredicateFuncs(func(obj client.Object) bool { - network := obj.(*v1alpha1.Network) - _, ok := getNetworkVNI(network) - return ok -}) - -func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager) error { +func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager, metalnetCache cache.Cache) error { return ctrl.NewControllerManagedBy(mgr). For( &v1alpha1.Network{}, - builder.WithPredicates(networkHasVNI), ). WatchesRawSource( - source.Kind(r.MetalnetCluster.GetCache(), &metalnetv1alpha1.Network{}), - r.enqueueNetworkUsingNetworkLabels(), + source.Kind(metalnetCache, &metalnetv1alpha1.Network{}), + metalnetlethandler.EnqueueRequestForSource(r.Scheme(), r.RESTMapper(), &v1alpha1.Network{}), ). Complete(r) } diff --git a/metalnetlet/controllers/network_controller_test.go b/metalnetlet/controllers/network_controller_test.go index 726e8e4c..9f13fcb1 100644 --- a/metalnetlet/controllers/network_controller_test.go +++ b/metalnetlet/controllers/network_controller_test.go @@ -16,17 +16,19 @@ package controllers import ( metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" - "github.com/onmetal/onmetal-api-net/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/networkid" + . "github.com/onmetal/onmetal-api/utils/testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" ) var _ = Describe("NetworkController", func() { - ns := SetupTest() + ns := SetupNamespace(&k8sClient) + metalnetNs := SetupNamespace(&k8sClient) + SetupTest(metalnetNs) It("should create a metalnet network for a network", func(ctx SpecContext) { By("creating a network") @@ -35,32 +37,25 @@ var _ = Describe("NetworkController", func() { Namespace: ns.Name, GenerateName: "network-", }, - Spec: v1alpha1.NetworkSpec{ - VNI: pointer.Int32(300), - }, + Spec: v1alpha1.NetworkSpec{}, } Expect(k8sClient.Create(ctx, network)).To(Succeed()) - By("patching the network to be available") - baseNetwork := network.DeepCopy() - network.Status.Conditions = []v1alpha1.NetworkCondition{ - { - Type: v1alpha1.NetworkAllocated, - Status: corev1.ConditionTrue, - Reason: "Allocated", - Message: "The network has been allocated.", - }, - } - Expect(k8sClient.Status().Patch(ctx, network, client.MergeFrom(baseNetwork))).Should(Succeed()) + By("parsing the VNI") + vni, err := networkid.ParseVNI(network.Spec.ID) + Expect(err).NotTo(HaveOccurred()) By("waiting for the metalnet network to be created") - metalnetNetwork := &metalnetv1alpha1.Network{} - metalnetNetworkKey := client.ObjectKey{Name: "network-300"} - Eventually(func(g Gomega) { - g.Expect(k8sClient.Get(ctx, metalnetNetworkKey, metalnetNetwork)).To(Succeed()) - g.Expect(metalnetNetwork.Spec).To(Equal(metalnetv1alpha1.NetworkSpec{ - ID: 300, - })) - }).Should(Succeed()) + metalnetNetwork := &metalnetv1alpha1.Network{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: metalnetNs.Name, + Name: string(network.UID), + }, + } + Eventually(Object(metalnetNetwork)).Should(SatisfyAll( + HaveField("Spec", metalnetv1alpha1.NetworkSpec{ + ID: vni, + }), + )) }) }) diff --git a/metalnetlet/controllers/networkinterface_controller.go b/metalnetlet/controllers/networkinterface_controller.go new file mode 100644 index 00000000..8fc69973 --- /dev/null +++ b/metalnetlet/controllers/networkinterface_controller.go @@ -0,0 +1,504 @@ +// Copyright 2023 OnMetal 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 controllers + +import ( + "context" + "fmt" + + "github.com/go-logr/logr" + "github.com/onmetal/controller-utils/clientutils" + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + metalnetletclient "github.com/onmetal/onmetal-api-net/metalnetlet/client" + utilhandler "github.com/onmetal/onmetal-api-net/metalnetlet/handler" + utilslices "github.com/onmetal/onmetal-api/utils/slices" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/sets" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +type NetworkInterfaceReconciler struct { + client.Client + MetalnetClient client.Client + + PartitionName string + + MetalnetNamespace string +} + +//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkinterfaces,verbs=get;list;watch;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkinterfaces/finalizers,verbs=update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=networkinterfaces/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=loadbalancerroutings,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=nattables,verbs=get;list;watch +//+kubebuilder:rbac:groups=core.apinet.api.onmetal.de,resources=natgateways,verbs=get;list;watch + +//+cluster=metalnet:kubebuilder:rbac:groups=networking.metalnet.onmetal.de,resources=networkinterfaces,verbs=get;list;watch;create;update;patch;delete;deletecollection +//+cluster=metalnet:kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch + +func (r *NetworkInterfaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := ctrl.LoggerFrom(ctx) + nic := &v1alpha1.NetworkInterface{} + if err := r.Get(ctx, req.NamespacedName, nic); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, err + } + + log.V(1).Info("Deleting all matching metalnet network interfaces") + exists, err := metalnetletclient.DeleteAllOfAndAnyExists(ctx, r.MetalnetClient, &metalnetv1alpha1.NetworkInterface{}, + client.InNamespace(r.MetalnetNamespace), + metalnetletclient.MatchingSourceKeyLabels(r.Scheme(), r.RESTMapper(), req.NamespacedName, &metalnetv1alpha1.NetworkInterface{}), + ) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error deleting matching metalnet network interfaces: %w", err) + } + if exists { + log.V(1).Info("Matching metalnet network interfaces are still present, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("All matching metalnet network interfaces are gone") + return ctrl.Result{}, nil + } + + return r.reconcileExists(ctx, log, nic) +} + +func (r *NetworkInterfaceReconciler) reconcileExists(ctx context.Context, log logr.Logger, nic *v1alpha1.NetworkInterface) (ctrl.Result, error) { + if !nic.DeletionTimestamp.IsZero() { + return r.delete(ctx, log, nic) + } + return r.reconcile(ctx, log, nic) +} + +func (r *NetworkInterfaceReconciler) delete(ctx context.Context, log logr.Logger, nic *v1alpha1.NetworkInterface) (ctrl.Result, error) { + log.V(1).Info("Delete") + if !controllerutil.ContainsFinalizer(nic, PartitionFinalizer(r.PartitionName)) { + log.V(1).Info("No partition finalizer present, nothing to do") + return ctrl.Result{}, nil + } + log.V(1).Info("Partition finalizer present, doing cleanup") + + log.V(1).Info("Deleting any matching metalnet network interface") + metalnetNic := &metalnetv1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.MetalnetNamespace, + Name: string(nic.UID), + }, + } + if err := r.MetalnetClient.Delete(ctx, metalnetNic); err != nil { + if !apierrors.IsNotFound(err) { + return ctrl.Result{}, fmt.Errorf("error deleting metalnet network interface %s: %w", metalnetNic.Name, err) + } + log.V(1).Info("Any matching metalnet network interface deleted") + + log.V(1).Info("Removing finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.MetalnetClient, nic, PartitionFinalizer(r.PartitionName)); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + log.V(1).Info("Finalizer removed") + return ctrl.Result{}, nil + } + log.V(1).Info("Issued metalnet network interface deletion, requeueing") + return ctrl.Result{Requeue: true}, nil +} + +func (r *NetworkInterfaceReconciler) getMetalnetNetworkNameForNetworkInterface(ctx context.Context, nic *v1alpha1.NetworkInterface) (string, error) { + network := &v1alpha1.Network{} + networkKey := client.ObjectKey{Namespace: nic.Namespace, Name: nic.Spec.NetworkRef.Name} + if err := r.Get(ctx, networkKey, network); err != nil { + if !apierrors.IsNotFound(err) { + return "", fmt.Errorf("error getting network %s: %w", networkKey.Name, err) + } + return "", nil + } + + return string(network.UID), nil +} + +func (r *NetworkInterfaceReconciler) getLoadBalancerTargetsForNetworkInterface(ctx context.Context, nic *v1alpha1.NetworkInterface) ([]net.IP, error) { + lbRoutingList := &v1alpha1.LoadBalancerRoutingList{} + if err := r.List(ctx, lbRoutingList, + client.InNamespace(nic.Namespace), + ); err != nil { + return nil, fmt.Errorf("error listing load balancer routings: %w", err) + } + + ipSet := sets.New[net.IP]() + for _, lbRouting := range lbRoutingList.Items { + hasDst := slices.ContainsFunc(lbRouting.Destinations, + func(dst v1alpha1.LoadBalancerDestination) bool { + return slices.Contains(nic.Spec.IPs, dst.IP) + }, + ) + if hasDst { + ipSet.Insert(lbRouting.IPs...) + } + } + + ips := ipSet.UnsortedList() + slices.SortFunc(ips, func(ip1, ip2 net.IP) bool { return ip1.Compare(ip2.Addr) < 0 }) + return ips, nil +} + +func (r *NetworkInterfaceReconciler) getNATDetailsForNetworkInterface( + ctx context.Context, + nic *v1alpha1.NetworkInterface, +) ([]metalnetv1alpha1.NATDetails, error) { + var res []metalnetv1alpha1.NATDetails + for _, nat := range nic.Spec.NATs { + natDetails, err := r.getNATIPsForNetworkInterfaceNAT(ctx, nic, &nat) + if err != nil { + return nil, err + } + if natDetails == nil { + continue + } + + res = append(res, *natDetails) + } + return res, nil +} + +func (r *NetworkInterfaceReconciler) getNATIPsForNetworkInterfaceNAT( + ctx context.Context, + nic *v1alpha1.NetworkInterface, + nat *v1alpha1.NetworkInterfaceNAT, +) (*metalnetv1alpha1.NATDetails, error) { + natGateway := &v1alpha1.NATGateway{} + natGatewayKey := client.ObjectKey{Namespace: nic.Namespace, Name: nat.ClaimRef.Name} + if err := r.Get(ctx, natGatewayKey, natGateway); err != nil { + if !apierrors.IsNotFound(err) { + return nil, err + } + return nil, nil + } + if natGateway.UID != nat.ClaimRef.UID { + return nil, nil + } + + natTable := &v1alpha1.NATTable{} + if err := r.Get(ctx, natGatewayKey, natTable); err != nil { + if !apierrors.IsNotFound(err) { + return nil, err + } + return nil, nil + } + + for _, natIP := range natTable.IPs { + for _, target := range natIP.Sections { + // TODO: Do matching based on IP in the future. + ref := target.TargetRef + if ref == nil || ref.UID != nic.UID { + continue + } + + return &metalnetv1alpha1.NATDetails{ + IP: &metalnetv1alpha1.IP{Addr: natIP.IP.Addr}, + Port: target.Port, + EndPort: target.EndPort, + }, nil + } + } + return nil, nil +} + +func (r *NetworkInterfaceReconciler) updateStatus( + ctx context.Context, + nic *v1alpha1.NetworkInterface, + metalnetNic *metalnetv1alpha1.NetworkInterface, +) error { + base := nic.DeepCopy() + if pciAddr := metalnetNic.Status.PCIAddress; pciAddr != nil { + nic.Status.PCIAddress = &v1alpha1.PCIAddress{ + Domain: pciAddr.Domain, + Bus: pciAddr.Bus, + Slot: pciAddr.Slot, + Function: pciAddr.Function, + } + } else { + nic.Status.PCIAddress = nil + } + nic.Status.PublicIPs = metalnetIPsToIPs(workaroundMetalnetNoIPv6IPToIPs(metalnetNic.Status.VirtualIP)) + nic.Status.NATIPs = metalnetIPsToIPs(workaroundMetalnetNoIPv6IPToIPs(metalnetNic.Status.NatIP)) + nic.Status.Prefixes = metalnetIPPrefixesToIPPrefixes(metalnetNic.Spec.Prefixes) + if err := r.Status().Patch(ctx, nic, client.MergeFrom(base)); err != nil { + return fmt.Errorf("error patching network interface status: %w", err) + } + return nil +} + +func (r *NetworkInterfaceReconciler) deleteMatchingMetalnetNetworkInterface(ctx context.Context, nic *v1alpha1.NetworkInterface) (existed bool, err error) { + metalnetNic := &metalnetv1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.MetalnetNamespace, + Name: string(nic.UID), + }, + } + if err := r.Delete(ctx, metalnetNic); err != nil { + if !apierrors.IsNotFound(err) { + return false, fmt.Errorf("error deleting metalnet network interface %s: %w", metalnetNic.Name, err) + } + + return false, nil + } + return true, nil +} + +func (r *NetworkInterfaceReconciler) reconcile(ctx context.Context, log logr.Logger, nic *v1alpha1.NetworkInterface) (ctrl.Result, error) { + log.V(1).Info("Reconcile") + + metalnetNode, err := GetMetalnetNode(ctx, r.PartitionName, r.MetalnetClient, nic.Spec.NodeRef.Name) + if err != nil { + return ctrl.Result{}, err + } + if metalnetNode == nil || !metalnetNode.DeletionTimestamp.IsZero() { + if !controllerutil.ContainsFinalizer(nic, PartitionFinalizer(r.PartitionName)) { + log.V(1).Info("Finalizer not present and metalnet node not found / deleting, nothing to do") + return ctrl.Result{}, nil + } + + log.V(1).Info("Finalizer present but metalnet node not found / deleting, cleaning up") + existed, err := r.deleteMatchingMetalnetNetworkInterface(ctx, nic) + if err != nil { + return ctrl.Result{}, err + } + if existed { + log.V(1).Info("Issued metalnet network interface deletion, requeueing") + return ctrl.Result{Requeue: true}, nil + } + + log.V(1).Info("Metalnet network interface is gone, removing partition finalizer") + if err := clientutils.PatchRemoveFinalizer(ctx, r.Client, nic, PartitionFinalizer(r.PartitionName)); err != nil { + return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) + } + log.V(1).Info("Removed partition finalizer") + return ctrl.Result{}, nil + } + log.V(1).Info("Metalnet node present and not deleting, ensuring finalizer") + modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, nic, PartitionFinalizer(r.PartitionName)) + if err != nil { + return ctrl.Result{}, err + } + if modified { + log.V(1).Info("Added finalizer, requeueing") + return ctrl.Result{Requeue: true}, nil + } + log.V(1).Info("Finalizer is present") + + log.V(1).Info("Managing metalnet network interface") + metalnetNic, ready, err := r.applyMetalnetNic(ctx, log, nic, metalnetNode.Name) + if err != nil { + return ctrl.Result{}, fmt.Errorf("error managing metalnet network interface: %w", err) + } + if !ready { + log.V(1).Info("Metalnet network interface is not yet ready") + return ctrl.Result{}, nil + } + + log.V(1).Info("Updating status") + if err := r.updateStatus(ctx, nic, metalnetNic); err != nil { + return ctrl.Result{}, fmt.Errorf("error updating status: %w", err) + } + + log.V(1).Info("Reconciled") + return ctrl.Result{}, nil +} + +func (r *NetworkInterfaceReconciler) applyMetalnetNic(ctx context.Context, log logr.Logger, nic *v1alpha1.NetworkInterface, metalnetNodeName string) (*metalnetv1alpha1.NetworkInterface, bool, error) { + log.V(1).Info("Getting network vni") + metalnetNetworkName, err := r.getMetalnetNetworkNameForNetworkInterface(ctx, nic) + if err != nil { + return nil, false, err + } + if metalnetNetworkName == "" { + log.V(1).Info("Network is not yet ready") + return nil, false, nil + } + + publicIPs := v1alpha1.GetNetworkInterfacePublicIPs(nic) + + log.V(1).Info("Getting load balancer targets") + targets, err := r.getLoadBalancerTargetsForNetworkInterface(ctx, nic) + if err != nil { + return nil, false, fmt.Errorf("error getting load balancer targets: %w", err) + } + + log.V(1).Info("Getting NAT IPs") + natIPs, err := r.getNATDetailsForNetworkInterface(ctx, nic) + if err != nil { + return nil, false, fmt.Errorf("error getting NAT IPs: %w", err) + } + + metalnetNic := &metalnetv1alpha1.NetworkInterface{ + TypeMeta: metav1.TypeMeta{ + APIVersion: metalnetv1alpha1.GroupVersion.String(), + Kind: "NetworkInterface", + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.MetalnetNamespace, + Name: string(nic.UID), + Labels: metalnetletclient.SourceLabels(r.Scheme(), r.RESTMapper(), nic), + }, + Spec: metalnetv1alpha1.NetworkInterfaceSpec{ + NetworkRef: corev1.LocalObjectReference{Name: metalnetNetworkName}, + IPFamilies: ipsIPFamilies(nic.Spec.IPs), + IPs: ipsToMetalnetIPs(nic.Spec.IPs), + VirtualIP: workaroundMetalnetNoIPv6VirtualIPSupportIPsToIP(ipsToMetalnetIPs(publicIPs)), + Prefixes: ipPrefixesToMetalnetPrefixes(nic.Spec.Prefixes), + LoadBalancerTargets: ipsToMetalnetIPPrefixes(targets), + NAT: workaroundMetalnetNoIPv6NATDetailsToNATDetailsPointer(natIPs), + NodeName: &metalnetNodeName, + }, + } + log.V(1).Info("Applying metalnet network interface") + if err := r.MetalnetClient.Patch(ctx, metalnetNic, client.Apply, MetalnetFieldOwner, client.ForceOwnership); err != nil { + return nil, false, fmt.Errorf("error applying metalnet network interface: %w", err) + } + return metalnetNic, true, nil +} + +func (r *NetworkInterfaceReconciler) isPartitionNetworkInterface() predicate.Predicate { + return predicate.NewPredicateFuncs(func(obj client.Object) bool { + nic := obj.(*v1alpha1.NetworkInterface) + _, err := ParseNodeName(r.PartitionName, nic.Spec.NodeRef.Name) + return err == nil + }) +} + +func (r *NetworkInterfaceReconciler) enqueueByNATTable() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + natTable := obj.(*v1alpha1.NATTable) + + var reqs []ctrl.Request + for _, natIP := range natTable.IPs { + for _, s := range natIP.Sections { + ref := s.TargetRef + if ref == nil { + continue + } + if _, err := ParseNodeName(r.PartitionName, ref.NodeRef.Name); err != nil { + continue + } + + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKey{ + Namespace: natTable.Namespace, + Name: ref.Name, + }}) + } + } + return reqs + }) +} + +func (r *NetworkInterfaceReconciler) enqueueByLoadBalancerRouting() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + loadBalancerRouting := obj.(*v1alpha1.LoadBalancerRouting) + log := ctrl.LoggerFrom(ctx) + + nicList := &v1alpha1.NetworkInterfaceList{} + if err := r.List(ctx, nicList, + client.InNamespace(loadBalancerRouting.Namespace), + ); err != nil { + log.Error(err, "Error listing network interfaces") + return nil + } + + metalnetNodeList := &corev1.NodeList{} + if err := r.MetalnetClient.List(ctx, metalnetNodeList); err != nil { + log.Error(err, "Error listing metalnet nodes") + return nil + } + + dstIPs := utilslices.ToSetFunc(loadBalancerRouting.Destinations, + func(dst v1alpha1.LoadBalancerDestination) net.IP { return dst.IP }, + ) + + var reqs []ctrl.Request + for _, nic := range nicList.Items { + if _, err := ParseNodeName(r.PartitionName, nic.Spec.NodeRef.Name); err != nil { + continue + } + + if dstIPs.HasAny(nic.Spec.IPs...) { + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&nic)}) + } + } + return reqs + }) +} + +func (r *NetworkInterfaceReconciler) enqueueByMetalnetNode() handler.EventHandler { + return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + metalnetNode := obj.(*corev1.Node) + log := ctrl.LoggerFrom(ctx) + + nicList := &v1alpha1.NetworkInterfaceList{} + if err := r.List(ctx, nicList); err != nil { + log.Error(err, "Error listing network interfaces") + return nil + } + + var ( + nodeName = PartitionNodeName(r.PartitionName, metalnetNode.Name) + reqs []ctrl.Request + ) + for _, nic := range nicList.Items { + if nic.Spec.NodeRef.Name != nodeName { + continue + } + + reqs = append(reqs, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(&nic)}) + } + return reqs + }) +} + +func (r *NetworkInterfaceReconciler) SetupWithManager(mgr ctrl.Manager, metalnetCache cache.Cache) error { + return ctrl.NewControllerManagedBy(mgr). + For( + &v1alpha1.NetworkInterface{}, + builder.WithPredicates(r.isPartitionNetworkInterface()), + ). + Watches( + &v1alpha1.NATTable{}, + r.enqueueByNATTable(), + ). + Watches( + &v1alpha1.LoadBalancerRouting{}, + r.enqueueByLoadBalancerRouting(), + ). + WatchesRawSource( + source.Kind(metalnetCache, &metalnetv1alpha1.NetworkInterface{}), + utilhandler.EnqueueRequestForSource(r.Scheme(), r.RESTMapper(), &v1alpha1.NetworkInterface{}), + ). + WatchesRawSource( + source.Kind(metalnetCache, &corev1.Node{}), + r.enqueueByMetalnetNode(), + ). + Complete(r) +} diff --git a/metalnetlet/controllers/networkinterface_controller_test.go b/metalnetlet/controllers/networkinterface_controller_test.go new file mode 100644 index 00000000..4a9741f8 --- /dev/null +++ b/metalnetlet/controllers/networkinterface_controller_test.go @@ -0,0 +1,84 @@ +// Copyright 2022 OnMetal 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 controllers + +import ( + metalnetv1alpha1 "github.com/onmetal/metalnet/api/v1alpha1" + "github.com/onmetal/onmetal-api-net/api/core/v1alpha1" + "github.com/onmetal/onmetal-api-net/apimachinery/api/net" + . "github.com/onmetal/onmetal-api/utils/testing" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" +) + +var _ = Describe("NetworkInterfaceController", func() { + ns := SetupNamespace(&k8sClient) + metalnetNs := SetupNamespace(&k8sClient) + SetupTest(metalnetNs) + + metalnetNode := SetupMetalnetNode() + network := SetupNetwork(ns) + + It("should create a metalnet network for a network", func(ctx SpecContext) { + By("creating a network") + + By("creating a network interface") + nic := &v1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + GenerateName: "nic-", + }, + Spec: v1alpha1.NetworkInterfaceSpec{ + NodeRef: corev1.LocalObjectReference{ + Name: PartitionNodeName(partitionName, metalnetNode.Name), + }, + NetworkRef: corev1.LocalObjectReference{ + Name: network.Name, + }, + IPs: []net.IP{ + net.MustParseIP("10.0.0.1"), + }, + }, + } + Expect(k8sClient.Create(ctx, nic)).To(Succeed()) + + By("waiting for the network interface to have a finalizer") + Eventually(Object(nic)).Should(HaveField("Finalizers", []string{PartitionFinalizer(partitionName)})) + + By("waiting for the metalnet network interface to be present with the expected values") + metalnetNic := &metalnetv1alpha1.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: metalnetNs.Name, + Name: string(nic.UID), + }, + } + Eventually(Object(metalnetNic)).Should(HaveField("Spec", metalnetv1alpha1.NetworkInterfaceSpec{ + NetworkRef: corev1.LocalObjectReference{Name: string(network.UID)}, + IPFamilies: []corev1.IPFamily{corev1.IPv4Protocol}, + IPs: []metalnetv1alpha1.IP{metalnetv1alpha1.MustParseIP("10.0.0.1")}, + NodeName: &metalnetNode.Name, + })) + + By("deleting the network interface") + Expect(k8sClient.Delete(ctx, nic)).To(Succeed()) + + By("waiting for the metalnet network interface to be gone") + Eventually(Get(metalnetNic)).Should(Satisfy(apierrors.IsNotFound)) + }) +}) diff --git a/metalnetlet/controllers/testdata/metalnet-crds/network.yaml b/metalnetlet/controllers/testdata/metalnet-crds/network.yaml deleted file mode 100644 index 4377b684..00000000 --- a/metalnetlet/controllers/testdata/metalnet-crds/network.yaml +++ /dev/null @@ -1,67 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.9.0 - creationTimestamp: null - name: networks.networking.metalnet.onmetal.de -spec: - group: networking.metalnet.onmetal.de - names: - kind: Network - listKind: NetworkList - plural: networks - singular: network - scope: Cluster - versions: - - additionalPrinterColumns: - - description: ID of the network. - jsonPath: .spec.id - name: Handle - priority: 10 - type: integer - - description: Age of the network. - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: Network is the Schema for the networks API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: NetworkSpec defines the desired state of Network - properties: - id: - description: ID is the unique identifier of the Network - format: int32 - maximum: 16777215 - minimum: 1 - type: integer - peeredIDs: - description: PeeredIDs are the IDs of networks to peer with. - items: - format: int32 - type: integer - type: array - required: - - id - type: object - type: object - served: true - storage: true - subresources: - status: {} \ No newline at end of file diff --git a/metalnetlet/handler/sourceaware.go b/metalnetlet/handler/sourceaware.go new file mode 100644 index 00000000..62af3699 --- /dev/null +++ b/metalnetlet/handler/sourceaware.go @@ -0,0 +1,26 @@ +// Copyright 2023 OnMetal 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 handler + +import ( + utilapi "github.com/onmetal/onmetal-api-net/utils/api" + utilhandler "github.com/onmetal/onmetal-api-net/utils/handler" +) + +var ( + SourceAwareSystem = utilhandler.NewSourceAwareSystem(utilapi.PrefixSourceAwareSystem("metalnetlet.api.onmetal.de/")) + + EnqueueRequestForSource = SourceAwareSystem.EnqueueRequestForSource +) diff --git a/models-schema/main.go b/models-schema/main.go new file mode 100644 index 00000000..336d7ad8 --- /dev/null +++ b/models-schema/main.go @@ -0,0 +1,97 @@ +// Copyright 2022 OnMetal 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 main + +import ( + "errors" + "flag" + "fmt" + "io/fs" + "os" + "os/exec" + "text/template" + + "github.com/go-logr/logr" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + + _ "embed" +) + +var ( + //go:embed main.go.tmpl + mainGoTemplateData string + + mainGoTemplate = template.Must(template.New("main.go").Parse(mainGoTemplateData)) +) + +type mainGoTemplateArgs struct { + OpenAPIPackage string + OpenAPITitle string +} + +func main() { + var ( + zapOpts = zap.Options{Development: true} + log logr.Logger + openapiPackage string + openapiTitle string + ) + + zapOpts.BindFlags(flag.CommandLine) + flag.StringVar(&openapiPackage, "openapi-package", "", "Package containing the openapi definitions.") + flag.StringVar(&openapiTitle, "openapi-title", "", "Title for the generated openapi json definition.") + flag.Parse() + log = zap.New(zap.UseFlagOptions(&zapOpts)) + + if openapiPackage == "" { + log.Error(fmt.Errorf("must specify openapi-package"), "Invalid flags") + os.Exit(1) + } + if openapiTitle == "" { + log.Error(fmt.Errorf("must specify openapi-title"), "Invalid flags") + os.Exit(1) + } + + if err := run(log, openapiPackage, openapiTitle); err != nil { + log.Error(err, "Error running models-schema") + } +} + +func run(log logr.Logger, openapiPackage, openapiTitle string) error { + tmpFile, err := os.CreateTemp("", "models-schema-*.go") + if err != nil { + return fmt.Errorf("error creating temporary file: %w", err) + } + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil && !errors.Is(err, fs.ErrNotExist) { + log.Error(err, "Error cleaning up temporary file") + } + }() + + if err := mainGoTemplate.Execute(tmpFile, mainGoTemplateArgs{ + OpenAPIPackage: openapiPackage, + OpenAPITitle: openapiTitle, + }); err != nil { + return fmt.Errorf("error executing template: %w", err) + } + + cmd := exec.Command("go", "run", tmpFile.Name()) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + if err := cmd.Run(); err != nil { + return fmt.Errorf("error running command: %w", err) + } + return nil +} diff --git a/models-schema/main.go.tmpl b/models-schema/main.go.tmpl new file mode 100644 index 00000000..7539b9af --- /dev/null +++ b/models-schema/main.go.tmpl @@ -0,0 +1,75 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "strings" + + "{{ .OpenAPIPackage }}" + "k8s.io/kube-openapi/pkg/common" + "k8s.io/kube-openapi/pkg/validation/spec" +) + +// Outputs openAPI schema JSON containing the schema definitions in zz_generated.openapi.go. +func main() { + err := output() + if err != nil { + os.Stderr.WriteString(fmt.Sprintf("Failed: %v", err)) + os.Exit(1) + } +} + +func output() error { + refFunc := func(name string) spec.Ref { + return spec.MustCreateRef(fmt.Sprintf("#/definitions/%s", friendlyName(name))) + } + defs := openapi.GetOpenAPIDefinitions(refFunc) + schemaDefs := make(map[string]spec.Schema, len(defs)) + for k, v := range defs { + // Replace top-level schema with v2 if a v2 schema is embedded + // so that the output of this program is always in OpenAPI v2. + // This is done by looking up an extension that marks the embedded v2 + // schema, and, if the v2 schema is found, make it the resulting schema for + // the type. + if schema, ok := v.Schema.Extensions[common.ExtensionV2Schema]; ok { + if v2Schema, isOpenAPISchema := schema.(spec.Schema); isOpenAPISchema { + schemaDefs[friendlyName(k)] = v2Schema + continue + } + } + + schemaDefs[friendlyName(k)] = v.Schema + } + data, err := json.Marshal(&spec.Swagger{ + SwaggerProps: spec.SwaggerProps{ + Definitions: schemaDefs, + Info: &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "{{ .OpenAPITitle }}", + Version: "unversioned", + }, + }, + Swagger: "2.0", + }, + }) + if err != nil { + return fmt.Errorf("error serializing api definitions: %w", err) + } + os.Stdout.Write(data) + return nil +} + +// From k8s.io/apiserver/pkg/endpoints/openapi/openapi.go +func friendlyName(name string) string { + nameParts := strings.Split(name, "/") + // Reverse first part. e.g., io.k8s... instead of k8s.io... + if len(nameParts) > 0 && strings.Contains(nameParts[0], ".") { + parts := strings.Split(nameParts[0], ".") + for i, j := 0, len(parts)-1; i < j; i, j = i+1, j-1 { + parts[i], parts[j] = parts[j], parts[i] + } + nameParts[0] = strings.Join(parts, ".") + } + return strings.Join(nameParts, ".") +} diff --git a/networkid/networkid.go b/networkid/networkid.go new file mode 100644 index 00000000..8b1a702d --- /dev/null +++ b/networkid/networkid.go @@ -0,0 +1,38 @@ +// Copyright 2023 OnMetal 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 networkid + +import ( + "errors" + "strconv" +) + +var ( + ErrInvalidVNI = errors.New("invalid VNI") +) + +func ParseVNI(id string) (int32, error) { + vni64, err := strconv.ParseInt(id, 10, 32) + if err != nil { + return 0, ErrInvalidVNI + } + + vni := int32(vni64) + return vni, nil +} + +func EncodeVNI(vni int32) string { + return strconv.FormatInt(int64(vni), 10) +} diff --git a/onmetal-api-net/controllers/controllers_suite_test.go b/onmetal-api-net/controllers/controllers_suite_test.go deleted file mode 100644 index 397726f5..00000000 --- a/onmetal-api-net/controllers/controllers_suite_test.go +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright 2022 The Metal 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 controllers - -import ( - "context" - "net/netip" - "path/filepath" - "testing" - "time" - - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - onmetalapinet "github.com/onmetal/onmetal-api-net/onmetal-api-net/controllers/certificate/onmetal-api-net" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "go4.org/netipx" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" - logf "sigs.k8s.io/controller-runtime/pkg/log" - //+kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment - -const ( - pollingInterval = 50 * time.Millisecond - eventuallyTimeout = 3 * time.Second - consistentlyDuration = 1 * time.Second -) - -func TestControllers(t *testing.T) { - SetDefaultConsistentlyPollingInterval(pollingInterval) - SetDefaultEventuallyPollingInterval(pollingInterval) - SetDefaultEventuallyTimeout(eventuallyTimeout) - SetDefaultConsistentlyDuration(consistentlyDuration) - - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -func InitialAvailableIPs() *netipx.IPSet { - var sb netipx.IPSetBuilder - sb.AddPrefix(netip.MustParsePrefix("10.0.0.0/31")) - set, _ := sb.IPSet() - return set -} - -const ( - NoOfIPv4Addresses = 2 - - MinVNI = 1 - MaxVNI = 2 - NoOfVNIs = (MaxVNI - MinVNI) + 1 -) - -var _ = BeforeSuite(func() { - logf.SetLogger(GinkgoLogr) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "onmetal-api-net", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - DeferCleanup(testEnv.Stop) - - err = onmetalapinetv1alpha1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - SetClient(k8sClient) - - k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - Host: "127.0.0.1", - MetricsBindAddress: "0", - }) - Expect(err).ToNot(HaveOccurred()) - - // register reconciler here - Expect((&PublicIPReconciler{ - EventRecorder: &record.FakeRecorder{}, - Client: k8sManager.GetClient(), - APIReader: k8sManager.GetAPIReader(), - InitialAvailableIPs: InitialAvailableIPs(), - }).SetupWithManager(k8sManager)).To(Succeed()) - - Expect((&NetworkReconciler{ - EventRecorder: &record.FakeRecorder{}, - Client: k8sManager.GetClient(), - APIReader: k8sManager.GetAPIReader(), - MinVNI: MinVNI, - MaxVNI: MaxVNI, - }).SetupWithManager(k8sManager)).To(Succeed()) - - Expect((&CertificateApprovalReconciler{ - Client: k8sManager.GetClient(), - Recognizers: onmetalapinet.Recognizers, - }).SetupWithManager(k8sManager)).To(Succeed()) - - mgrCtx, cancel := context.WithCancel(context.Background()) - DeferCleanup(cancel) - go func() { - defer GinkgoRecover() - Expect(k8sManager.Start(mgrCtx)).To(Succeed(), "failed to start manager") - }() -}) - -func SetupTest() *corev1.Namespace { - ns := &corev1.Namespace{} - - BeforeEach(func(ctx SpecContext) { - - *ns = corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "testns-", - }, - } - Expect(k8sClient.Create(ctx, ns)).To(Succeed(), "failed to create test namespace") - - DeferCleanup(func(ctx context.Context) { - Expect(k8sClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.Network{}, client.InNamespace(ns.Name))).To(Succeed(), "failed to delete networks") - Expect(k8sClient.DeleteAllOf(ctx, &onmetalapinetv1alpha1.PublicIP{}, client.InNamespace(ns.Name))).To(Succeed(), "failed to delete public ips") - Expect(k8sClient.Delete(ctx, ns)).To(Succeed(), "failed to delete test namespace") - }) - }) - - return ns -} diff --git a/onmetal-api-net/controllers/network_controller.go b/onmetal-api-net/controllers/network_controller.go deleted file mode 100644 index 528924cc..00000000 --- a/onmetal-api-net/controllers/network_controller.go +++ /dev/null @@ -1,396 +0,0 @@ -// Copyright 2022 OnMetal 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 controllers - -import ( - "context" - "fmt" - "sync" - - "github.com/go-logr/logr" - "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/manager" -) - -const ( - DefaultMinVNI int32 = 200 - DefaultMaxVNI int32 = (1 << 24) - 1 - - networkFinalizer = "apinet.api.onmetal.de/network" -) - -type networkAllocation struct { - UID types.UID - VNI int32 -} - -type NetworkReconciler struct { - mu sync.RWMutex - - record.EventRecorder - client.Client - APIReader client.Reader - - MinVNI int32 - MaxVNI int32 - - allocationsByKey map[client.ObjectKey]networkAllocation - taken sets.Set[int32] - released chan struct{} -} - -//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=networks,verbs=get;list;watch;update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=networks/finalizers,verbs=update -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=networks/status,verbs=get;update;patch - -func (r *NetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx) - network := &onmetalapinetv1alpha1.Network{} - if err := r.Get(ctx, req.NamespacedName, network); err != nil { - if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error getting network %s: %w", req.NamespacedName, err) - } - - r.release(ctx, req.NamespacedName) - return ctrl.Result{}, nil - } - - return r.reconcileExists(ctx, log, network) -} - -func (r *NetworkReconciler) release(ctx context.Context, key client.ObjectKey) { - r.mu.Lock() - defer r.mu.Unlock() - - allocation, ok := r.allocationsByKey[key] - if !ok { - return - } - - r.taken.Delete(allocation.VNI) - delete(r.allocationsByKey, key) - - select { - case <-ctx.Done(): - case r.released <- struct{}{}: - } -} - -func (r *NetworkReconciler) allocate(ctx context.Context, network *onmetalapinetv1alpha1.Network) (int32, error) { - r.mu.Lock() - defer r.mu.Unlock() - - key := client.ObjectKeyFromObject(network) - allocation, ok := r.allocationsByKey[key] - if ok { - if allocation.UID == network.UID { - return allocation.VNI, nil - } - - r.taken.Delete(allocation.VNI) - delete(r.allocationsByKey, key) - - select { - case <-ctx.Done(): - case r.released <- struct{}{}: - } - } - - if vni := network.Spec.VNI; vni != nil { - if r.taken.Has(*vni) { - return 0, fmt.Errorf("vni %d is already taken", *vni) - } - - r.taken.Insert(*vni) - r.allocationsByKey[key] = networkAllocation{ - UID: network.UID, - VNI: *vni, - } - return *vni, nil - } - - if allVNIsTaken(r.taken, r.MinVNI, r.MaxVNI) { - return 0, fmt.Errorf("no vni available") - } - - vni := r.MinVNI - for ; r.taken.Has(vni); vni++ { - } - - r.taken.Insert(vni) - r.allocationsByKey[key] = networkAllocation{ - UID: network.UID, - VNI: vni, - } - return vni, nil -} - -func (r *NetworkReconciler) reconcileExists(ctx context.Context, log logr.Logger, network *onmetalapinetv1alpha1.Network) (ctrl.Result, error) { - if !network.DeletionTimestamp.IsZero() { - return r.delete(ctx, log, network) - } - return r.reconcile(ctx, log, network) -} - -func (r *NetworkReconciler) delete(ctx context.Context, log logr.Logger, network *onmetalapinetv1alpha1.Network) (ctrl.Result, error) { - log.V(1).Info("Delete") - - log.V(1).Info("Releasing any associated vnis") - r.release(ctx, client.ObjectKeyFromObject(network)) - - log.V(1).Info("Ensuring finalizer is not present anymore") - if _, err := clientutils.PatchEnsureNoFinalizer(ctx, r.Client, network, networkFinalizer); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) - } - - log.V(1).Info("Deleted") - return ctrl.Result{}, nil -} - -func (r *NetworkReconciler) reconcile(ctx context.Context, log logr.Logger, network *onmetalapinetv1alpha1.Network) (ctrl.Result, error) { - log.V(1).Info("Reconcile") - - log.V(1).Info("Ensuring finalizer") - modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, network, networkFinalizer) - if err != nil { - return ctrl.Result{}, fmt.Errorf("error ensuring finalizer: %w", err) - } - if modified { - log.V(1).Info("Added finalizer, requeueing") - return ctrl.Result{Requeue: true}, nil - } - log.V(1).Info("Finalizer is present") - - if _, ok := network.Annotations[onmetalapinetv1alpha1.ReconcileRequestAnnotation]; ok { - log.V(1).Info("Removing reconcile annotation") - if err := PatchRemoveReconcileAnnotation(ctx, r.Client, network); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing reconcile annotation: %w", err) - } - log.V(1).Info("Removed reconcile annotation, requeueing") - return ctrl.Result{Requeue: true}, nil - } - - log.V(1).Info("Allocating") - vni, err := r.allocate(ctx, network) - if err != nil { - log.V(1).Info("Error allocating, patching as pending", "Error", err) - r.Eventf(network, corev1.EventTypeNormal, FailedAllocatingNetwork, "Failed allocating: %w", err) - if err := r.patchStatusPending(ctx, network); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Successfully marked as pending") - return ctrl.Result{}, nil - } - - log = log.WithValues("VNI", vni) - log.V(1).Info("Successfully allocated") - - if network.Spec.VNI == nil { - log.V(1).Info("Patching allocated vni into spec") - if err := r.patchSpecVNI(ctx, network, vni); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Patched allocated vni into spec, requeueing") - return ctrl.Result{Requeue: true}, nil - } - - log.V(1).Info("Patching as allocated") - if err := r.patchStatusAllocated(ctx, network); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Patched as allocated") - - log.V(1).Info("Reconciled") - return ctrl.Result{}, nil -} - -func (r *NetworkReconciler) patchSpecVNI(ctx context.Context, network *onmetalapinetv1alpha1.Network, vni int32) error { - base := network.DeepCopy() - network.Spec.VNI = &vni - if err := r.Patch(ctx, network, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching spec vni: %w", err) - } - return nil -} - -func (r *NetworkReconciler) patchStatusPending(ctx context.Context, network *onmetalapinetv1alpha1.Network) error { - base := network.DeepCopy() - onmetalapinetv1alpha1.SetNetworkCondition(&network.Status.Conditions, onmetalapinetv1alpha1.NetworkCondition{ - Type: onmetalapinetv1alpha1.NetworkAllocated, - Reason: "Pending", - Status: corev1.ConditionFalse, - Message: "The network could not yet be allocated.", - }) - if err := r.Status().Patch(ctx, network, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching status: %w", err) - } - return nil -} - -func (r *NetworkReconciler) patchStatusAllocated(ctx context.Context, network *onmetalapinetv1alpha1.Network) error { - base := network.DeepCopy() - onmetalapinetv1alpha1.SetNetworkCondition(&network.Status.Conditions, onmetalapinetv1alpha1.NetworkCondition{ - Type: onmetalapinetv1alpha1.NetworkAllocated, - Reason: "Allocated", - Status: corev1.ConditionTrue, - Message: "The network was successfully allocated.", - }) - if err := r.Status().Patch(ctx, network, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching status: %w", err) - } - return nil -} - -func (r *NetworkReconciler) isAllocated(network *onmetalapinetv1alpha1.Network) bool { - idx := onmetalapinetv1alpha1.NetworkConditionIndex(network.Status.Conditions, onmetalapinetv1alpha1.NetworkAllocated) - return idx != -1 && network.Status.Conditions[idx].Status == corev1.ConditionTrue -} - -func (r *NetworkReconciler) initialize(ctx context.Context) error { - if r.MinVNI <= 0 { - return fmt.Errorf("min vni %d has to be > 0", r.MinVNI) - } - if r.MaxVNI < r.MinVNI { - return fmt.Errorf("max vni %d has to be >= min vni %d", r.MaxVNI, r.MinVNI) - } - - r.taken = sets.New[int32]() - r.allocationsByKey = make(map[client.ObjectKey]networkAllocation) - r.released = make(chan struct{}, 1024) - - networkList := &onmetalapinetv1alpha1.NetworkList{} - if err := r.APIReader.List(ctx, networkList); err != nil { - return fmt.Errorf("error listing networks: %w", err) - } - - for _, network := range networkList.Items { - networkKey := client.ObjectKeyFromObject(&network) - if !r.isAllocated(&network) { - continue - } - - vni := *network.Spec.VNI - if r.taken.Has(vni) || vni > r.MaxVNI { - return fmt.Errorf("[network %s] cannot allocate vni %d", networkKey, vni) - } - - r.taken.Insert(vni) - r.allocationsByKey[networkKey] = networkAllocation{ - UID: network.UID, - VNI: vni, - } - } - - return nil -} - -func (r *NetworkReconciler) determineReconciliationCandidates(networks []onmetalapinetv1alpha1.Network) []onmetalapinetv1alpha1.Network { - r.mu.RLock() - defer r.mu.RUnlock() - - if allVNIsTaken(r.taken, r.MinVNI, r.MaxVNI) { - return nil - } - - var candidates []onmetalapinetv1alpha1.Network - for _, network := range networks { - if !network.DeletionTimestamp.IsZero() { - continue - } - - if r.isAllocated(&network) { - continue - } - - if network.Spec.VNI != nil && r.taken.Has(*network.Spec.VNI) { - continue - } - - candidates = append(candidates, network) - } - return candidates -} - -func allVNIsTaken(taken sets.Set[int32], minVNI, maxVNI int32) bool { - return int32(taken.Len()) == (maxVNI-minVNI)+1 -} - -func (r *NetworkReconciler) requeueNetworkCandidates(ctx context.Context) error { - log := ctrl.LoggerFrom(ctx).WithName("network").WithName("requeue-candidates") - for { - select { - case <-ctx.Done(): - log.V(1).Info("Shutting down candidate requeuing") - return nil - case <-r.released: - if err := func() error { - log.V(1).Info("VNI released") - - log.V(1).Info("Listing networks") - networkList := &onmetalapinetv1alpha1.NetworkList{} - if err := r.List(ctx, networkList); err != nil { - return fmt.Errorf("error listing networks: %w", err) - } - - log.V(1).Info("Determining candidates") - candidates := r.determineReconciliationCandidates(networkList.Items) - - var errs []error - for _, candidate := range candidates { - log.V(1).Info("Requesting reconciliation", "CandidateKey", client.ObjectKeyFromObject(&candidate)) - if err := PatchAddReconcileAnnotation(ctx, r.Client, &candidate); err != nil { - errs = append(errs, err) - } - } - - if len(errs) > 0 { - return fmt.Errorf("error(s) requesting candidate reconciliation(s): %v", errs) - } - log.V(1).Info("Handled vni release") - return nil - }(); err != nil { - log.Error(err, "Error requeuing network candidates") - } - } - } -} - -func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager) error { - return mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { - setupLog := ctrl.LoggerFrom(ctx).WithName("network").WithName("setup") - setupLog.V(1).Info("Initializing") - if err := r.initialize(ctx); err != nil { - return fmt.Errorf("error initializing: %w", err) - } - setupLog.V(1).Info("Initialized") - - if err := mgr.Add(manager.RunnableFunc(r.requeueNetworkCandidates)); err != nil { - return fmt.Errorf("error adding requeue network candidates runnable: %w", err) - } - - return ctrl.NewControllerManagedBy(mgr). - For(&onmetalapinetv1alpha1.Network{}). - Complete(r) - })) -} diff --git a/onmetal-api-net/controllers/network_controller_test.go b/onmetal-api-net/controllers/network_controller_test.go deleted file mode 100644 index eb1b65bd..00000000 --- a/onmetal-api-net/controllers/network_controller_test.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2022 OnMetal 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 controllers - -import ( - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/types" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" -) - -var _ = Describe("NetworkController", func() { - ns := SetupTest() - - It("should allocate a vni", func(ctx SpecContext) { - By("creating a network") - network := &onmetalapinetv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", - }, - Spec: onmetalapinetv1alpha1.NetworkSpec{}, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - By("waiting for the network to be allocated") - Eventually(Object(network)).Should(BeAllocatedNetwork()) - }) - - It("should mark networks as pending if they can't be allocated and allocate them as soon as there's space", func(ctx SpecContext) { - By("creating networks until we run out of vnis") - networkKeys := make([]client.ObjectKey, NoOfVNIs) - for i := 0; i < NoOfVNIs; i++ { - network := &onmetalapinetv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "block-network-", - }, - Spec: onmetalapinetv1alpha1.NetworkSpec{}, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - networkKeys[i] = client.ObjectKeyFromObject(network) - - By("waiting for the network to be allocated") - Eventually(Object(network)).Should(BeAllocatedNetwork()) - } - - By("creating another network") - network := &onmetalapinetv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "network-", - }, - Spec: onmetalapinetv1alpha1.NetworkSpec{}, - } - Expect(k8sClient.Create(ctx, network)).To(Succeed()) - - By("waiting for the network to be marked as non-allocated") - Eventually(Object(network)).Should(BeUnallocatedNetwork()) - - By("asserting it stays that way") - Consistently(Object(network)).Should(BeUnallocatedNetwork()) - - By("deleting one of the original networks") - Expect(k8sClient.Delete(ctx, &onmetalapinetv1alpha1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: networkKeys[0].Namespace, - Name: networkKeys[0].Name, - }, - })).To(Succeed()) - - By("waiting for the network to be allocated") - Eventually(Object(network)).Should(BeAllocatedNetwork()) - }) -}) - -func BeUnallocatedNetwork() types.GomegaMatcher { - return HaveField("Status", SatisfyAll( - HaveField("Conditions", ConsistOf( - SatisfyAll( - HaveField("Type", onmetalapinetv1alpha1.NetworkAllocated), - HaveField("Status", corev1.ConditionFalse), - )), - ), - )) -} - -func BeAllocatedNetwork() types.GomegaMatcher { - return SatisfyAll( - HaveField("Spec.VNI", HaveValue(SatisfyAll( - BeNumerically(">=", MinVNI), - BeNumerically("<=", MaxVNI), - ))), - HaveField("Status", SatisfyAll( - HaveField("Conditions", ConsistOf( - SatisfyAll( - HaveField("Type", onmetalapinetv1alpha1.NetworkAllocated), - HaveField("Status", corev1.ConditionTrue), - )), - ), - )), - ) -} diff --git a/onmetal-api-net/controllers/publicip_controller.go b/onmetal-api-net/controllers/publicip_controller.go deleted file mode 100644 index 135a8663..00000000 --- a/onmetal-api-net/controllers/publicip_controller.go +++ /dev/null @@ -1,441 +0,0 @@ -// Copyright 2022 OnMetal 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 controllers - -import ( - "context" - "fmt" - "net/netip" - "sync" - - "github.com/go-logr/logr" - "github.com/onmetal/controller-utils/clientutils" - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - "go4.org/netipx" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/manager" -) - -const ( - publicIPFinalizer = "apinet.api.onmetal.de/publicip" -) - -type publicIPAllocation struct { - UID types.UID - IP netip.Addr -} - -type publicIPAllocations struct { - availableIPs *netipx.IPSet - allocationsByKey map[client.ObjectKey]publicIPAllocation -} - -func newPublicIPAllocations(availableIPs *netipx.IPSet) *publicIPAllocations { - return &publicIPAllocations{ - availableIPs: availableIPs, - allocationsByKey: make(map[client.ObjectKey]publicIPAllocation), - } -} - -func (p *publicIPAllocations) get(key client.ObjectKey) *publicIPAllocation { - allocation, ok := p.allocationsByKey[key] - if ok { - return &allocation - } - return nil -} - -func (p *publicIPAllocations) delete(key client.ObjectKey) *publicIPAllocation { - deleted, ok := p.allocationsByKey[key] - if !ok { - return nil - } - - var sb netipx.IPSetBuilder - sb.AddSet(p.availableIPs) - sb.Add(deleted.IP) - - p.availableIPs, _ = sb.IPSet() - delete(p.allocationsByKey, key) - - return &deleted -} - -type publicIPAllocationRequest struct { - ipFamily corev1.IPFamily - ip netip.Addr -} - -func (p *publicIPAllocations) canFit(req publicIPAllocationRequest) bool { - if req.ip.IsValid() { - return p.availableIPs.Contains(req.ip) - } - - _, _, ok := p.availableIPs.RemoveFreePrefix(IPFamilyBitLen(req.ipFamily)) - return ok -} - -func (p *publicIPAllocations) allocate(key client.ObjectKey, uid types.UID, req publicIPAllocationRequest) (netip.Addr, error) { - if _, ok := p.allocationsByKey[key]; ok { - return netip.Addr{}, fmt.Errorf("allocation for %s already exists", key) - } - - if req.ip.IsValid() { - ip := req.ip - if !p.availableIPs.Contains(ip) { - return netip.Addr{}, fmt.Errorf("ip %s is not available for allocation", ip) - } - - var sb netipx.IPSetBuilder - sb.AddSet(p.availableIPs) - sb.Remove(ip) - set, _ := sb.IPSet() - - p.availableIPs = set - p.allocationsByKey[key] = publicIPAllocation{ - UID: uid, - IP: ip, - } - return ip, nil - } else { - prefix, set, ok := p.availableIPs.RemoveFreePrefix(IPFamilyBitLen(req.ipFamily)) - if !ok { - return netip.Addr{}, fmt.Errorf("no free prefix available for ip family %s", req.ipFamily) - } - - ip := prefix.Addr() - - p.availableIPs = set - p.allocationsByKey[key] = publicIPAllocation{ - UID: uid, - IP: ip, - } - return ip, nil - } -} - -type PublicIPReconciler struct { - mu sync.RWMutex - - record.EventRecorder - client.Client - APIReader client.Reader - InitialAvailableIPs *netipx.IPSet - - allocations *publicIPAllocations - released chan struct{} -} - -//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips,verbs=get;list;watch;update;patch -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips/finalizers,verbs=update -//+kubebuilder:rbac:groups=apinet.api.onmetal.de,resources=publicips/status,verbs=get;update;patch - -func (r *PublicIPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx) - publicIP := &onmetalapinetv1alpha1.PublicIP{} - if err := r.APIReader.Get(ctx, req.NamespacedName, publicIP); err != nil { - if !apierrors.IsNotFound(err) { - return ctrl.Result{}, fmt.Errorf("error getting public ip %s: %w", req.NamespacedName, err) - } - - r.release(ctx, req.NamespacedName) - return ctrl.Result{}, nil - } - - return r.reconcileExists(ctx, log, publicIP) -} - -func (r *PublicIPReconciler) reconcileExists(ctx context.Context, log logr.Logger, publicIP *onmetalapinetv1alpha1.PublicIP) (ctrl.Result, error) { - if !publicIP.DeletionTimestamp.IsZero() { - return r.delete(ctx, log, publicIP) - } - return r.reconcile(ctx, log, publicIP) -} - -func (r *PublicIPReconciler) delete(ctx context.Context, log logr.Logger, publicIP *onmetalapinetv1alpha1.PublicIP) (ctrl.Result, error) { - log.V(1).Info("Delete") - - log.V(1).Info("Releasing any associated ips") - r.release(ctx, client.ObjectKeyFromObject(publicIP)) - - log.V(1).Info("Ensuring finalizer is not present anymore") - if _, err := clientutils.PatchEnsureNoFinalizer(ctx, r.Client, publicIP, publicIPFinalizer); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing finalizer: %w", err) - } - - log.V(1).Info("Deleted") - return ctrl.Result{}, nil -} - -func (r *PublicIPReconciler) emitReleased(ctx context.Context) { - select { - case <-ctx.Done(): - case r.released <- struct{}{}: - } -} - -func (r *PublicIPReconciler) release(ctx context.Context, key client.ObjectKey) { - r.mu.Lock() - defer r.mu.Unlock() - - if deleted := r.allocations.delete(key); deleted != nil { - r.emitReleased(ctx) - } -} - -func (r *PublicIPReconciler) allocate(ctx context.Context, log logr.Logger, publicIP *onmetalapinetv1alpha1.PublicIP) (netip.Addr, error) { - r.mu.Lock() - defer r.mu.Unlock() - - key := client.ObjectKeyFromObject(publicIP) - if allocation := r.allocations.get(key); allocation != nil { - if allocation.UID == publicIP.UID { - log.V(1).Info("Retrieved existing allocation", "UID", allocation.UID, "IP", allocation.IP) - return allocation.IP, nil - } - - log.V(1).Info("Current allocation is outdated, releasing it", "UID", allocation.UID, "IP", allocation.IP) - r.allocations.delete(key) - r.emitReleased(ctx) - } - - req := publicIPAllocationRequestFromPublicIP(publicIP) - log.V(1).Info("Requesting new allocation", "Request", req) - return r.allocations.allocate(key, publicIP.UID, req) -} - -func publicIPAllocationRequestFromPublicIP(publicIP *onmetalapinetv1alpha1.PublicIP) publicIPAllocationRequest { - var ip netip.Addr - if reqIP := publicIP.Spec.IP; reqIP != nil { - ip = reqIP.Addr - } - req := publicIPAllocationRequest{ - ipFamily: publicIP.Spec.IPFamily, - ip: ip, - } - return req -} - -func (r *PublicIPReconciler) reconcile(ctx context.Context, log logr.Logger, publicIP *onmetalapinetv1alpha1.PublicIP) (ctrl.Result, error) { - log.V(1).Info("Reconcile") - - log.V(1).Info("Ensuring finalizer") - modified, err := clientutils.PatchEnsureFinalizer(ctx, r.Client, publicIP, publicIPFinalizer) - if err != nil { - return ctrl.Result{}, fmt.Errorf("error ensuring finalizer: %w", err) - } - if modified { - log.V(1).Info("Added finalizer, requeueing") - return ctrl.Result{Requeue: true}, nil - } - log.V(1).Info("Finalizer is present") - - if _, ok := publicIP.Annotations[onmetalapinetv1alpha1.ReconcileRequestAnnotation]; ok { - log.V(1).Info("Removing reconcile annotation") - if err := PatchRemoveReconcileAnnotation(ctx, r.Client, publicIP); err != nil { - return ctrl.Result{}, fmt.Errorf("error removing reconcile annotation: %w", err) - } - log.V(1).Info("Removed reconcile annotation, requeueing") - return ctrl.Result{Requeue: true}, nil - } - - log.V(1).Info("Allocating") - ip, err := r.allocate(ctx, log, publicIP) - if err != nil { - log.V(1).Info("Error allocating, patching public ip as pending", "Error", err) - r.Eventf(publicIP, corev1.EventTypeNormal, FailedAllocatingPublicIP, "Failed allocating: %w", err) - if err := r.patchStatusPending(ctx, publicIP); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Successfully marked public ip as pending") - return ctrl.Result{}, nil - } - - log = log.WithValues("IP", ip) - log.V(1).Info("Successfully allocated") - - if publicIP.Spec.IP == nil { - log.V(1).Info("Patching allocated ip into spec") - if err := r.patchPublicIPSpecIP(ctx, publicIP, ip); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Patched allocated ip into spec, requeueing") - return ctrl.Result{Requeue: true}, nil - } - - log.V(1).Info("Patching public ip as allocated") - if err := r.patchStatusAllocated(ctx, publicIP); err != nil { - return ctrl.Result{}, err - } - log.V(1).Info("Patched public ip status") - - log.V(1).Info("Reconciled") - return ctrl.Result{}, nil -} - -func (r *PublicIPReconciler) patchPublicIPSpecIP(ctx context.Context, publicIP *onmetalapinetv1alpha1.PublicIP, ip netip.Addr) error { - base := publicIP.DeepCopy() - publicIP.Spec.IP = &onmetalapinetv1alpha1.IP{Addr: ip} - if err := r.Patch(ctx, publicIP, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching spec ips: %w", err) - } - return nil -} - -func (r *PublicIPReconciler) patchStatusPending(ctx context.Context, publicIP *onmetalapinetv1alpha1.PublicIP) error { - base := publicIP.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Reason: "Pending", - Status: corev1.ConditionFalse, - Message: "The public ip could not yet be allocated.", - }) - if err := r.Status().Patch(ctx, publicIP, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching status: %w", err) - } - return nil -} - -func (r *PublicIPReconciler) patchStatusAllocated(ctx context.Context, publicIP *onmetalapinetv1alpha1.PublicIP) error { - base := publicIP.DeepCopy() - onmetalapinetv1alpha1.SetPublicIPCondition(&publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPCondition{ - Type: onmetalapinetv1alpha1.PublicIPAllocated, - Reason: "Allocated", - Status: corev1.ConditionTrue, - Message: "The public ip was successfully allocated.", - }) - if err := r.Status().Patch(ctx, publicIP, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error patching status: %w", err) - } - return nil -} - -func (r *PublicIPReconciler) isAllocated(publicIP *onmetalapinetv1alpha1.PublicIP) bool { - idx := onmetalapinetv1alpha1.PublicIPConditionIndex(publicIP.Status.Conditions, onmetalapinetv1alpha1.PublicIPAllocated) - return idx != -1 && publicIP.Status.Conditions[idx].Status == corev1.ConditionTrue -} - -func (r *PublicIPReconciler) initialize(ctx context.Context) error { - r.allocations = newPublicIPAllocations(r.InitialAvailableIPs) - r.released = make(chan struct{}, 1024) - publicIPList := &onmetalapinetv1alpha1.PublicIPList{} - if err := r.APIReader.List(ctx, publicIPList); err != nil { - return fmt.Errorf("error listing public ips: %w", err) - } - - var sb netipx.IPSetBuilder - sb.AddSet(r.InitialAvailableIPs) - - for _, publicIP := range publicIPList.Items { - publicIPKey := client.ObjectKeyFromObject(&publicIP) - if !r.isAllocated(&publicIP) { - continue - } - - req := publicIPAllocationRequestFromPublicIP(&publicIP) - if _, err := r.allocations.allocate(publicIPKey, publicIP.UID, req); err != nil { - return fmt.Errorf("[public ip %s] cannot allocate: %w", publicIPKey, err) - } - } - - return nil -} - -func (r *PublicIPReconciler) determineReconciliationCandidates(publicIPs []onmetalapinetv1alpha1.PublicIP) []onmetalapinetv1alpha1.PublicIP { - r.mu.RLock() - defer r.mu.RUnlock() - - var candidates []onmetalapinetv1alpha1.PublicIP - for _, publicIP := range publicIPs { - if !publicIP.DeletionTimestamp.IsZero() { - continue - } - - if r.isAllocated(&publicIP) { - continue - } - - req := publicIPAllocationRequestFromPublicIP(&publicIP) - if r.allocations.canFit(req) { - candidates = append(candidates, publicIP) - } - } - return candidates -} - -func (r *PublicIPReconciler) requeuePublicIPCandidates(ctx context.Context) error { - log := ctrl.LoggerFrom(ctx).WithName("publicip").WithName("requeue-candidates") - for { - select { - case <-ctx.Done(): - log.V(1).Info("Shutting down candidate requeuing") - return nil - case <-r.released: - if err := func() error { - log.V(1).Info("IP released") - - log.V(1).Info("Listing public ips") - publicIPList := &onmetalapinetv1alpha1.PublicIPList{} - if err := r.List(ctx, publicIPList); err != nil { - return fmt.Errorf("error listing public ips: %w", err) - } - - log.V(1).Info("Determining candidates") - candidates := r.determineReconciliationCandidates(publicIPList.Items) - - var errs []error - for _, candidate := range candidates { - log.V(1).Info("Requesting reconciliation", "CandidateKey", client.ObjectKeyFromObject(&candidate)) - if err := PatchAddReconcileAnnotation(ctx, r.Client, &candidate); err != nil { - errs = append(errs, err) - } - } - - if len(errs) > 0 { - return fmt.Errorf("error(s) requesting candidate reconciliation(s): %v", errs) - } - log.V(1).Info("Handled ip release") - return nil - }(); err != nil { - log.Error(err, "Error requeuing public ip candidates") - } - } - } -} - -func (r *PublicIPReconciler) SetupWithManager(mgr ctrl.Manager) error { - return mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { - setupLog := ctrl.LoggerFrom(ctx).WithName("publicip").WithName("setup") - setupLog.V(1).Info("Initializing") - if err := r.initialize(ctx); err != nil { - return fmt.Errorf("error initializing: %w", err) - } - setupLog.V(1).Info("Initialized") - - if err := mgr.Add(manager.RunnableFunc(r.requeuePublicIPCandidates)); err != nil { - return fmt.Errorf("error adding requeue public ip candidates runnable: %w", err) - } - - return ctrl.NewControllerManagedBy(mgr). - For(&onmetalapinetv1alpha1.PublicIP{}). - Complete(r) - })) -} diff --git a/onmetal-api-net/controllers/publicip_controller_test.go b/onmetal-api-net/controllers/publicip_controller_test.go deleted file mode 100644 index 89a32bf6..00000000 --- a/onmetal-api-net/controllers/publicip_controller_test.go +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2022 OnMetal 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 controllers - -import ( - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/types" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" -) - -var _ = Describe("PublicIPController", func() { - ns := SetupTest() - - It("should allocate a public ip", func(ctx SpecContext) { - By("creating a public ip") - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "public-ip-", - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - - By("waiting for the public ip to be allocated") - Eventually(Object(publicIP)).Should(BeAllocatedPublicIP()) - }) - - It("should mark public ips as pending if they can't be allocated and allocate them as soon as there's space", func(ctx SpecContext) { - By("creating public ips until we run out of addresses") - publicIPKeys := make([]client.ObjectKey, NoOfIPv4Addresses) - for i := 0; i < NoOfIPv4Addresses; i++ { - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "block-public-ip-", - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - publicIPKeys[i] = client.ObjectKeyFromObject(publicIP) - - By("waiting for the public ip to be allocated") - Eventually(Object(publicIP)).Should(BeAllocatedPublicIP()) - } - - By("creating another public ip") - publicIP := &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "public-ip-", - }, - Spec: onmetalapinetv1alpha1.PublicIPSpec{ - IPFamily: corev1.IPv4Protocol, - }, - } - Expect(k8sClient.Create(ctx, publicIP)).To(Succeed()) - - By("waiting for the public ip to be marked as non-allocated") - Eventually(Object(publicIP)).Should(BeUnallocatedPublicIP()) - - By("asserting it stays that way") - Consistently(Object(publicIP)).Should(BeUnallocatedPublicIP()) - - By("deleting one of the original public ips") - Expect(k8sClient.Delete(ctx, &onmetalapinetv1alpha1.PublicIP{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: publicIPKeys[0].Namespace, - Name: publicIPKeys[0].Name, - }, - })).To(Succeed()) - - By("waiting for the ip to be allocated") - Eventually(Object(publicIP)).Should(BeAllocatedPublicIP()) - }) -}) - -func BeUnallocatedPublicIP() types.GomegaMatcher { - return HaveField("Status", SatisfyAll( - HaveField("Conditions", ConsistOf( - SatisfyAll( - HaveField("Type", onmetalapinetv1alpha1.PublicIPAllocated), - HaveField("Status", corev1.ConditionFalse), - )), - ), - )) -} - -func BeAllocatedPublicIP() types.GomegaMatcher { - return SatisfyAll( - HaveField("Spec.IP", Satisfy(func(ip *onmetalapinetv1alpha1.IP) bool { - return ip != nil && ip.Is4() && ip.IsValid() && InitialAvailableIPs().Contains(ip.Addr) - })), - HaveField("Status", SatisfyAll( - HaveField("Conditions", ConsistOf( - SatisfyAll( - HaveField("Type", onmetalapinetv1alpha1.PublicIPAllocated), - HaveField("Status", corev1.ConditionTrue), - )), - ), - )), - ) -} diff --git a/onmetal-api-net/controllers/util.go b/onmetal-api-net/controllers/util.go deleted file mode 100644 index 1372336e..00000000 --- a/onmetal-api-net/controllers/util.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2022 OnMetal 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 controllers - -import ( - "context" - "fmt" - "net/netip" - "time" - - onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1" - corev1 "k8s.io/api/core/v1" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func IPFamilyBitLen(ipFamily corev1.IPFamily) uint8 { - switch ipFamily { - case corev1.IPv4Protocol: - return 32 - case corev1.IPv6Protocol: - return 128 - default: - return 0 - } -} - -func APINetV1Alpha1IPsToNetIPAddrs(ips []onmetalapinetv1alpha1.IP) []netip.Addr { - res := make([]netip.Addr, len(ips)) - for i, ip := range ips { - res[i] = ip.Addr - } - return res -} - -func NetIPAddrsToAPINetV1Alpha1IPs(addrs []netip.Addr) []onmetalapinetv1alpha1.IP { - res := make([]onmetalapinetv1alpha1.IP, len(addrs)) - for i, addr := range addrs { - res[i] = onmetalapinetv1alpha1.IP{Addr: addr} - } - return res -} - -func PatchAddReconcileAnnotation(ctx context.Context, c client.Client, obj client.Object) error { - base := obj.DeepCopyObject().(client.Object) - - annotations := obj.GetAnnotations() - if annotations == nil { - annotations = make(map[string]string) - } - - annotations[onmetalapinetv1alpha1.ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano) - obj.SetAnnotations(annotations) - - if err := c.Patch(ctx, obj, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error adding reconcile annotation: %w", err) - } - return nil -} - -func PatchRemoveReconcileAnnotation(ctx context.Context, c client.Client, obj client.Object) error { - base := obj.DeepCopyObject().(client.Object) - - annotations := obj.GetAnnotations() - delete(annotations, onmetalapinetv1alpha1.ReconcileRequestAnnotation) - - if err := c.Patch(ctx, obj, client.MergeFrom(base)); err != nil { - return fmt.Errorf("error removing reconcile annotation: %w", err) - } - return nil -} diff --git a/utils/api/sourceaware.go b/utils/api/sourceaware.go new file mode 100644 index 00000000..b959a91e --- /dev/null +++ b/utils/api/sourceaware.go @@ -0,0 +1,44 @@ +// Copyright 2023 OnMetal 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 api + +import "strings" + +type SourceAwareSystem struct { + SourceUIDLabel func(kind string) string + SourceNameLabel func(kind string) string + SourceNamespaceLabel func(kind string) string +} + +func PrefixSourceAwareSystem(prefix string) SourceAwareSystem { + mkLabelFunc := func(name string) func(kind string) string { + return func(kind string) string { + var sb strings.Builder + // "-" + sb.Grow(len(prefix) + len(kind) + 1 + len(name)) + sb.WriteString(prefix) + sb.WriteString(strings.ToLower(kind)) + sb.WriteRune('-') + sb.WriteString(name) + return sb.String() + } + } + + return SourceAwareSystem{ + SourceUIDLabel: mkLabelFunc("uid"), + SourceNameLabel: mkLabelFunc("name"), + SourceNamespaceLabel: mkLabelFunc("namespace"), + } +} diff --git a/utils/cache/util.go b/utils/cache/util.go new file mode 100644 index 00000000..d215e636 --- /dev/null +++ b/utils/cache/util.go @@ -0,0 +1,63 @@ +// Copyright 2023 OnMetal 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 cache + +import ( + "context" + "errors" + "fmt" + "time" + + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/wait" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func PollGetInformer(ctx context.Context, c cache.Cache, object client.Object) (cache.Informer, error) { + var ( + log = ctrl.LoggerFrom(ctx) + i cache.Informer + lastErr error + ) + // Tries to get an informer until it returns true, + // an error or the specified context is cancelled or expired. + if err := wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(ctx context.Context) (bool, error) { + // Lookup the Informer from the Cache and add an EventHandler which populates the Queue + i, lastErr = c.GetInformer(ctx, object) + if lastErr != nil { + kindMatchErr := &meta.NoKindMatchError{} + switch { + case errors.As(lastErr, &kindMatchErr): + log.Error(lastErr, "if kind is a CRD, it should be installed before calling Start", + "kind", kindMatchErr.GroupKind) + case runtime.IsNotRegisteredError(lastErr): + log.Error(lastErr, "kind must be registered to the Scheme") + default: + log.Error(lastErr, "failed to get informer from cache") + } + return false, nil // Retry. + } + return true, nil + }); err != nil { + if lastErr != nil { + return nil, fmt.Errorf("failed to get informer from cache: %w", lastErr) + } + return nil, err + } + return i, nil +} diff --git a/utils/client/sourceaware.go b/utils/client/sourceaware.go new file mode 100644 index 00000000..83973e86 --- /dev/null +++ b/utils/client/sourceaware.go @@ -0,0 +1,275 @@ +// Copyright 2023 OnMetal 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 client + +import ( + "github.com/onmetal/onmetal-api-net/utils/api" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" +) + +type SourceAwareSystem struct { + api.SourceAwareSystem +} + +func NewSourceAwareSystemE(system api.SourceAwareSystem) (*SourceAwareSystem, error) { + return &SourceAwareSystem{system}, nil +} + +func NewSourceAwareSystem(system api.SourceAwareSystem) *SourceAwareSystem { + s, err := NewSourceAwareSystemE(system) + if err != nil { + panic(err) + } + return s +} + +func (s *SourceAwareSystem) SourceLabelKeysE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) ([]string, error) { + sourceGVK, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + return nil, err + } + + sourceNamespaced, err := apiutil.IsGVKNamespaced(sourceGVK, mapper) + if err != nil { + return nil, err + } + + keys := []string{ + s.SourceUIDLabel(sourceGVK.Kind), + s.SourceNameLabel(sourceGVK.Kind), + } + if sourceNamespaced { + keys = append(keys, s.SourceNamespaceLabel(sourceGVK.Kind)) + } + + return keys, nil +} + +func (s *SourceAwareSystem) SourceLabelKeys(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) []string { + keys, err := s.SourceLabelKeysE(scheme, mapper, sourceObj) + if err != nil { + panic(err) + } + return keys +} + +func (s *SourceAwareSystem) SourceLabelsE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) (map[string]string, error) { + sourceGVK, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + return nil, err + } + + sourceNamespaced, err := apiutil.IsGVKNamespaced(sourceGVK, mapper) + if err != nil { + return nil, err + } + + lbls := map[string]string{ + s.SourceUIDLabel(sourceGVK.Kind): string(sourceObj.GetUID()), + s.SourceNameLabel(sourceGVK.Kind): sourceObj.GetName(), + } + if sourceNamespaced { + lbls[s.SourceNamespaceLabel(sourceGVK.Kind)] = sourceObj.GetNamespace() + } + + return lbls, nil +} + +func (s *SourceAwareSystem) SourceLabels(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) map[string]string { + lbls, err := s.SourceLabelsE(scheme, mapper, sourceObj) + if err != nil { + panic(err) + } + return lbls +} + +func (s *SourceAwareSystem) MatchingSourceLabelsE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) (client.MatchingLabels, error) { + lbls, err := s.SourceLabelsE(scheme, mapper, sourceObj) + if err != nil { + return nil, err + } + + return lbls, nil +} + +func (s *SourceAwareSystem) MatchingSourceLabels(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) client.MatchingLabels { + matchingLbls, err := s.MatchingSourceLabelsE(scheme, mapper, sourceObj) + if err != nil { + panic(err) + } + + return matchingLbls +} + +func (s *SourceAwareSystem) HasSourceLabelsE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj, obj client.Object) (bool, error) { + sourceLabels, err := s.SourceLabelsE(scheme, mapper, sourceObj) + if err != nil { + return false, err + } + + sel := labels.SelectorFromSet(sourceLabels) + return sel.Matches(labels.Set(obj.GetLabels())), nil +} + +func (s *SourceAwareSystem) HasSourceLabels(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj, obj client.Object) bool { + ok, err := s.HasSourceLabelsE(scheme, mapper, sourceObj, obj) + if err != nil { + panic(err) + } + return ok +} + +func (s *SourceAwareSystem) SourceKeyLabelsE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceKey client.ObjectKey, sourceObj client.Object) (map[string]string, error) { + sourceGVK, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + return nil, err + } + + sourceNamespaced, err := apiutil.IsGVKNamespaced(sourceGVK, mapper) + if err != nil { + return nil, err + } + + lbls := map[string]string{ + s.SourceNameLabel(sourceGVK.Kind): sourceKey.Name, + } + if sourceNamespaced { + lbls[s.SourceNamespaceLabel(sourceGVK.Kind)] = sourceKey.Namespace + } + + return lbls, nil +} + +func (s *SourceAwareSystem) SourceKeyLabels(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceKey client.ObjectKey, sourceObj client.Object) map[string]string { + lbls, err := s.SourceKeyLabelsE(scheme, mapper, sourceKey, sourceObj) + if err != nil { + panic(err) + } + + return lbls +} + +func (s *SourceAwareSystem) MatchingSourceKeyLabelsE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceKey client.ObjectKey, sourceObj client.Object) (client.MatchingLabels, error) { + lbls, err := s.SourceKeyLabelsE(scheme, mapper, sourceKey, sourceObj) + if err != nil { + return nil, err + } + + return lbls, nil +} + +func (s *SourceAwareSystem) MatchingSourceKeyLabels(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceKey client.ObjectKey, sourceObj client.Object) client.MatchingLabels { + lbls, err := s.MatchingSourceKeyLabelsE(scheme, mapper, sourceKey, sourceObj) + if err != nil { + panic(err) + } + return lbls +} + +func (s *SourceAwareSystem) SourceObjectKeyFromObjectE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object, obj client.Object) (*client.ObjectKey, error) { + sourceGVK, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + return nil, err + } + + sourceNamespaced, err := apiutil.IsGVKNamespaced(sourceGVK, mapper) + if err != nil { + return nil, err + } + + lbls := obj.GetLabels() + + var namespace string + if sourceNamespaced { + var ok bool + namespace, ok = lbls[s.SourceNamespaceLabel(sourceGVK.Kind)] + if !ok { + return nil, nil + } + } + + name, ok := lbls[s.SourceNameLabel(sourceGVK.Kind)] + if !ok { + return nil, nil + } + + return &client.ObjectKey{Namespace: namespace, Name: name}, nil +} + +func (s *SourceAwareSystem) SourceObjectKeyFromObject(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object, obj client.Object) *client.ObjectKey { + key, err := s.SourceObjectKeyFromObjectE(scheme, mapper, sourceObj, obj) + if err != nil { + panic(err) + } + return key +} + +type SourceObjectData struct { + Namespace string + Name string + UID types.UID +} + +func (s *SourceAwareSystem) SourceObjectDataFromObjectE(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object, obj client.Object) (*SourceObjectData, error) { + sourceGVK, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + return nil, err + } + + sourceNamespaced, err := apiutil.IsGVKNamespaced(sourceGVK, mapper) + if err != nil { + return nil, err + } + + lbls := obj.GetLabels() + + var namespace string + if sourceNamespaced { + var ok bool + namespace, ok = lbls[s.SourceNamespaceLabel(sourceGVK.Kind)] + if !ok { + return nil, nil + } + } + + name, ok := lbls[s.SourceNameLabel(sourceGVK.Kind)] + if !ok { + return nil, nil + } + + uid, ok := lbls[s.SourceUIDLabel(sourceGVK.Kind)] + if !ok { + return nil, nil + } + + return &SourceObjectData{ + Namespace: namespace, + Name: name, + UID: types.UID(uid), + }, nil +} + +func (s *SourceAwareSystem) SourceObjectDataFromObject(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object, obj client.Object) *SourceObjectData { + data, err := s.SourceObjectDataFromObjectE(scheme, mapper, sourceObj, obj) + if err != nil { + panic(err) + } + return data +} diff --git a/utils/container/bimap.go b/utils/container/bimap.go new file mode 100644 index 00000000..04e08a7b --- /dev/null +++ b/utils/container/bimap.go @@ -0,0 +1,111 @@ +// Copyright 2023 OnMetal 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 container + +type BiMap[K, V comparable] struct { + forward map[K]V + inverse map[V]K +} + +type BiMapOptions[K, V comparable] struct { + Len *int +} + +func (o *BiMapOptions[K, V]) ApplyToBiMap(o2 *BiMapOptions[K, V]) { + if o.Len != nil { + o2.Len = o.Len + } +} + +func (o *BiMapOptions[K, V]) ApplyOptions(opts []BiMapOption[K, V]) *BiMapOptions[K, V] { + for _, opt := range opts { + opt.ApplyToBiMap(o) + } + return o +} + +type BiMapOption[K, V comparable] interface { + ApplyToBiMap(o *BiMapOptions[K, V]) +} + +type WithLen[K, V comparable] int + +func (w WithLen[K, V]) ApplyToBiMap(o *BiMapOptions[K, V]) { + o.Len = (*int)(&w) +} + +func NewBiMap[K, V comparable](opts ...BiMapOption[K, V]) *BiMap[K, V] { + o := (&BiMapOptions[K, V]{}).ApplyOptions(opts) + + var ( + forward map[K]V + inverse map[V]K + ) + if o.Len != nil { + forward = make(map[K]V, *o.Len) + inverse = make(map[V]K, *o.Len) + } else { + forward = make(map[K]V) + inverse = make(map[V]K) + } + + return &BiMap[K, V]{ + forward: forward, + inverse: inverse, + } +} + +func (b *BiMap[K, V]) Insert(k K, v V) { + b.forward[k] = v + b.inverse[v] = k +} + +func (b *BiMap[K, V]) Delete(k K) { + v, ok := b.forward[k] + if !ok { + return + } + delete(b.forward, k) + delete(b.inverse, v) +} + +func (b *BiMap[K, V]) Has(k K) bool { + _, ok := b.forward[k] + return ok +} + +func (b *BiMap[K, V]) Get(k K) (V, bool) { + v, ok := b.forward[k] + return v, ok +} + +func (b *BiMap[K, V]) GetValue(k K) V { + return b.forward[k] +} + +func (b *BiMap[K, V]) Range(f func(K, V) bool) { + for k, v := range b.forward { + if !f(k, v) { + return + } + } +} + +func (b *BiMap[K, V]) Inverse() *BiMap[V, K] { + return &BiMap[V, K]{ + forward: b.inverse, + inverse: b.forward, + } +} diff --git a/utils/container/rmap.go b/utils/container/rmap.go new file mode 100644 index 00000000..56ee71e5 --- /dev/null +++ b/utils/container/rmap.go @@ -0,0 +1,139 @@ +// Copyright 2023 OnMetal 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 container + +import "k8s.io/apimachinery/pkg/util/sets" + +type MapIndex[K comparable, V any] interface { + Update(k K, old, new V) + Put(k K, v V) + Delete(k K, v V) +} + +type ReverseMapIndex[K, V comparable] map[V]sets.Set[K] + +func (r ReverseMapIndex[K, V]) Update(k K, old, new V) { + if old == new { + return + } + + r.Delete(k, old) + r.Put(k, new) +} + +func (r ReverseMapIndex[K, V]) Put(k K, v V) { + keys := r[v] + if keys == nil { + keys = sets.New[K]() + r[v] = keys + } + keys.Insert(k) +} + +func (r ReverseMapIndex[K, V]) Delete(k K, v V) { + keys := r[v] + keys.Delete(k) + if keys.Len() == 0 { + delete(r, v) + } +} + +func (r ReverseMapIndex[K, V]) Get(v V) sets.Set[K] { + return r[v] +} + +type IndexingMap[K comparable, V any] struct { + entries map[K]V + indices []MapIndex[K, V] +} + +func (r *IndexingMap[K, V]) forEachIndex(f func(MapIndex[K, V])) { + if r == nil { + return + } + + for _, idx := range r.indices { + f(idx) + } +} + +func (r *IndexingMap[K, V]) AddIndex(idx ...MapIndex[K, V]) { + if r == nil { + panic("AddIndex on nil IndexingMap") + } + + for k, v := range r.entries { + for _, idx := range idx { + idx.Put(k, v) + } + } + r.indices = append(r.indices, idx...) +} + +func (r *IndexingMap[K, V]) Put(k K, v V) { + if r == nil { + panic("Put on nil IndexingMap") + } + + if r.entries == nil { + r.entries = make(map[K]V) + } + oldV, ok := r.entries[k] + r.entries[k] = v + if ok { + r.forEachIndex(func(idx MapIndex[K, V]) { + idx.Update(k, oldV, v) + }) + } else { + r.forEachIndex(func(idx MapIndex[K, V]) { + idx.Put(k, v) + }) + } +} + +func (r *IndexingMap[K, V]) Delete(k K) { + if r == nil { + return + } + v, ok := r.entries[k] + if !ok { + return + } + r.forEachIndex(func(idx MapIndex[K, V]) { + idx.Delete(k, v) + }) +} + +func (r *IndexingMap[K, V]) Get(k K) (V, bool) { + if r == nil { + var zero V + return zero, false + } + + v, ok := r.entries[k] + return v, ok +} + +func (r *IndexingMap[K, V]) Range(f func(K, V) bool) { + if r == nil { + return + } + + for k, v := range r.entries { + if !f(k, v) { + return + } + } +} diff --git a/utils/container/slots.go b/utils/container/slots.go new file mode 100644 index 00000000..c120ea9c --- /dev/null +++ b/utils/container/slots.go @@ -0,0 +1,121 @@ +// Copyright 2023 OnMetal 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 container + +import ( + "github.com/bits-and-blooms/bitset" + "golang.org/x/exp/maps" + "k8s.io/apimachinery/pkg/util/sets" +) + +type KeySlots[K comparable] struct { + slotsPerKey uint + used uint + slotsByKey map[K]*bitset.BitSet + freeKeys sets.Set[K] +} + +func NewKeySlots[K comparable](slotsPerKey uint, keys []K) *KeySlots[K] { + var ( + slotsByKey = make(map[K]*bitset.BitSet) + freeKeys = sets.New[K]() + ) + + for _, key := range keys { + if _, ok := slotsByKey[key]; ok { + // don't re-initialize on duplicate ips + continue + } + + slotsByKey[key] = bitset.New(slotsPerKey) + freeKeys.Insert(key) + } + + return &KeySlots[K]{ + slotsPerKey: slotsPerKey, + slotsByKey: slotsByKey, + freeKeys: freeKeys, + } +} + +func (s *KeySlots[K]) HasKey(key K) bool { + _, ok := s.slotsByKey[key] + return ok +} + +func (s *KeySlots[K]) Keys() []K { + return maps.Keys(s.slotsByKey) +} + +// Total returns the total number of slots. +func (s *KeySlots[K]) Total() uint { + if s == nil { + return 0 + } + return uint(len(s.slotsByKey)) * s.slotsPerKey +} + +// Used returns the used number of slots. +func (s *KeySlots[K]) Used() uint { + if s == nil { + return 0 + } + return s.used +} + +func (s *KeySlots[K]) Use(key K, slot uint) bool { + if s == nil { + return false + } + // Test whether the slot is valid at all. + if slot >= s.slotsPerKey { + return false + } + + slots, ok := s.slotsByKey[key] + if !ok || slots.Test(slot) { + return false + } + + slots.Set(slot) + s.used++ + if slots.All() { + s.freeKeys.Delete(key) + } + return true +} + +func (s *KeySlots[K]) UseNextFree() (K, uint, bool) { + if s == nil { + var zero K + return zero, 0, false + } + + // Shortcut if there are no free keys. + if s.freeKeys.Len() == 0 { + var zero K + return zero, 0, false + } + + for key := range s.freeKeys { + slot, ok := s.slotsByKey[key].NextClear(0) + if ok { + s.Use(key, slot) + return key, slot, true + } + } + var zero K + return zero, 0, false +} diff --git a/utils/controller/refmanager.go b/utils/controller/refmanager.go new file mode 100644 index 00000000..323eec98 --- /dev/null +++ b/utils/controller/refmanager.go @@ -0,0 +1,146 @@ +// Copyright 2023 OnMetal 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 controller + +import ( + "context" + "sync" + + "github.com/onmetal/onmetal-api/utils/generic" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" +) + +func MatchLabelSelectorFunc[O client.Object](sel labels.Selector) func(O) bool { + return func(obj O) bool { + return sel.Matches(labels.Set(obj.GetLabels())) + } +} + +type RefManager[O client.Object] struct { + client client.Client + controller client.Object + match func(O) bool + + gvkOnce sync.Once + gvk schema.GroupVersionKind + gvkErr error +} + +func NewRefManager[O client.Object](c client.Client, controller client.Object, match func(O) bool) *RefManager[O] { + return &RefManager[O]{ + client: c, + controller: controller, + match: match, + } +} + +func (r *RefManager[O]) getGVK() (schema.GroupVersionKind, error) { + r.gvkOnce.Do(func() { + r.gvk, r.gvkErr = apiutil.GVKForObject(r.controller, r.client.Scheme()) + }) + return r.gvk, r.gvkErr +} + +func (r *RefManager[O]) adopt(ctx context.Context, obj O) error { + gvk, err := r.getGVK() + if err != nil { + return err + } + + base := obj.DeepCopyObject().(client.Object) + obj.SetOwnerReferences(append(obj.GetOwnerReferences(), metav1.OwnerReference{ + APIVersion: gvk.GroupVersion().String(), + Kind: gvk.Kind, + Name: r.controller.GetName(), + UID: r.controller.GetUID(), + Controller: generic.Pointer(true), + BlockOwnerDeletion: generic.Pointer(true), + })) + return r.client.Patch(ctx, obj, client.StrategicMergeFrom(base)) +} + +func (r *RefManager[O]) release(ctx context.Context, obj O) error { + var ( + ownerRefs = obj.GetOwnerReferences() + filtered []metav1.OwnerReference + ) + for _, ownerRef := range ownerRefs { + if ownerRef.UID == r.controller.GetUID() { + continue + } + + filtered = append(filtered, ownerRef) + } + + base := obj.DeepCopyObject().(client.Object) + obj.SetOwnerReferences(filtered) + return r.client.Patch(ctx, obj, client.StrategicMergeFrom(base)) +} + +func (r *RefManager[O]) ClaimObject( + ctx context.Context, + obj O, +) (bool, error) { + controllerRef := metav1.GetControllerOf(obj) + if controllerRef != nil { + if controllerRef.UID != r.controller.GetUID() { + // Owned by someone else. Ignore + return false, nil + } + + if r.match(obj) { + // We own it and match. All OK. + return true, nil + } + + if !r.controller.GetDeletionTimestamp().IsZero() { + // Don't try to own if we're deleting. + return false, nil + } + + if err := r.release(ctx, obj); err != nil { + if !apierrors.IsNotFound(err) { + return false, err + } + // If it's already gone, don't care about it. + return false, nil + } + return false, nil + } + + if !r.controller.GetDeletionTimestamp().IsZero() || !r.match(obj) { + // Ignore if we're being deleted or don't match. + return false, nil + } + if !obj.GetDeletionTimestamp().IsZero() { + // Ignore if the object is being deleted. + return false, nil + } + + if err := r.adopt(ctx, obj); err != nil { + if !apierrors.IsNotFound(err) { + return false, err + } + // If it's already gone, ignore it. + return false, nil + } + // Successfully adopted. + return true, nil +} diff --git a/apiutils/apiutils.go b/utils/core/core.go similarity index 68% rename from apiutils/apiutils.go rename to utils/core/core.go index 32205725..3aa1abb5 100644 --- a/apiutils/apiutils.go +++ b/utils/core/core.go @@ -12,18 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package apiutils +package core import ( - "github.com/onmetal/onmetal-api-net/api/v1alpha1" + "net/netip" + corev1 "k8s.io/api/core/v1" ) -func IsNetworkAllocated(network *v1alpha1.Network) bool { - for _, condition := range network.Status.Conditions { - if condition.Type == v1alpha1.NetworkAllocated { - return condition.Status == corev1.ConditionTrue - } +func IPFamilyForAddr(addr netip.Addr) corev1.IPFamily { + switch { + case addr.Is4(): + return corev1.IPv4Protocol + case addr.Is6(): + return corev1.IPv6Protocol + default: + return "" } - return false } diff --git a/utils/expectations/expectations.go b/utils/expectations/expectations.go new file mode 100644 index 00000000..001e3c62 --- /dev/null +++ b/utils/expectations/expectations.go @@ -0,0 +1,208 @@ +// Copyright 2023 OnMetal 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 expectations + +import ( + "time" + + "github.com/onmetal/onmetal-api/broker/common/sync" + utilclient "github.com/onmetal/onmetal-api/utils/client" + utilrand "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/validation" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type expectation struct { + timestamp time.Time + delete sets.Set[client.ObjectKey] + create sets.Set[client.ObjectKey] +} + +type Expectations struct { + timeout time.Duration + + entriesMu *sync.MutexMap[client.ObjectKey] + entries map[client.ObjectKey]*expectation +} + +type NewOptions struct { + Timeout time.Duration +} + +func setNewOptionsDefaults(o *NewOptions) { + if o.Timeout <= 0 { + o.Timeout = 5 * time.Minute + } +} + +func (o *NewOptions) ApplyOptions(opts []NewOption) { + for _, opt := range opts { + opt.ApplyToNew(o) + } +} + +func (o *NewOptions) ApplyToNew(o2 *NewOptions) { + if o.Timeout > 0 { + o2.Timeout = o.Timeout + } +} + +type NewOption interface { + ApplyToNew(o *NewOptions) +} + +type WithTimeout time.Duration + +func (w WithTimeout) ApplyToNew(o *NewOptions) { + o.Timeout = time.Duration(w) +} + +func New(opts ...NewOption) *Expectations { + o := &NewOptions{} + o.ApplyOptions(opts) + setNewOptionsDefaults(o) + + return &Expectations{ + timeout: o.Timeout, + entriesMu: sync.NewMutexMap[client.ObjectKey](), + entries: make(map[client.ObjectKey]*expectation), + } +} + +func (e *Expectations) Delete(ctrlKey client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + delete(e.entries, ctrlKey) +} + +func (e *Expectations) ExpectDeletions(ctrlKey client.ObjectKey, deletedKeys []client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + e.entries[ctrlKey] = &expectation{ + timestamp: time.Now(), + delete: sets.New(deletedKeys...), + } +} + +func (e *Expectations) ExpectCreations(ctrlKey client.ObjectKey, createdKeys []client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + e.entries[ctrlKey] = &expectation{ + timestamp: time.Now(), + create: sets.New(createdKeys...), + } +} + +func (e *Expectations) ExpectCreationsAndDeletions(ctrlKey client.ObjectKey, createdKeys, deletedKeys []client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + e.entries[ctrlKey] = &expectation{ + timestamp: time.Now(), + create: sets.New(createdKeys...), + delete: sets.New(deletedKeys...), + } +} + +func (e *Expectations) CreationObserved(ctrlKey, createdKey client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + exp, ok := e.entries[ctrlKey] + if !ok { + return + } + + exp.create.Delete(createdKey) +} + +func (e *Expectations) DeletionObserved(ctrlKey, deletedKey client.ObjectKey) { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + exp, ok := e.entries[ctrlKey] + if !ok { + return + } + + exp.delete.Delete(deletedKey) +} + +func (e *Expectations) Satisfied(ctrlKey client.ObjectKey) bool { + e.entriesMu.Lock(ctrlKey) + defer e.entriesMu.Unlock(ctrlKey) + + exp, ok := e.entries[ctrlKey] + if !ok { + // We didn't record any expectation and are good to go. + return true + } + if time.Since(exp.timestamp) > e.timeout { + // Expectations timed out, release. + return true + } + if exp.create.Len() == 0 && exp.delete.Len() == 0 { + // All expectations satisfied + return true + } + + // There are still some pending expectations. + return false +} + +// TODO: Make all these constants configurable via dynamic options in GenerateCreateNames. +const ( + maxObjectNameLength = validation.DNS1035LabelMaxLength + noOfObjectGenerateNameRandomChars = 10 + maxGenerateNamePrefixLength = maxObjectNameLength - noOfObjectGenerateNameRandomChars - 1 // -1 for the '-' +) + +func GenerateCreateNames(name string, ct int) []string { + prefix := name + if len(prefix) > maxGenerateNamePrefixLength { + prefix = prefix[:maxGenerateNamePrefixLength] + } + prefix = prefix + "-" + + names := sets.New[string]() + for names.Len() < ct { + name := prefix + utilrand.String(noOfObjectGenerateNameRandomChars) + names.Insert(name) + } + return names.UnsortedList() +} + +func ObjectKeysFromNames(namespace string, names []string) []client.ObjectKey { + keys := make([]client.ObjectKey, len(names)) + for i, name := range names { + keys[i] = client.ObjectKey{ + Namespace: namespace, + Name: name, + } + } + return keys +} + +func ObjectKeysFromObjectStructSlice[O utilclient.Object[OStruct], S ~[]OStruct, OStruct any](objs S) []client.ObjectKey { + keys := make([]client.ObjectKey, len(objs)) + for i, obj := range objs { + keys[i] = client.ObjectKeyFromObject(O(&obj)) + } + return keys +} diff --git a/utils/generic/generic.go b/utils/generic/generic.go new file mode 100644 index 00000000..92a001ff --- /dev/null +++ b/utils/generic/generic.go @@ -0,0 +1,30 @@ +// Copyright 2023 OnMetal 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 generic + +func EqualPointers[E comparable](e1, e2 *E) bool { + e1Nil := e1 == nil + e2Nil := e2 == nil + if e1Nil != e2Nil { + // Nil-ness of pointers is different - not equal. + return false + } + if e1Nil { + // Both are nil - equal. + return true + } + // Do actual comparison. + return *e1 == *e2 +} diff --git a/utils/handler/expectations.go b/utils/handler/expectations.go new file mode 100644 index 00000000..691f9add --- /dev/null +++ b/utils/handler/expectations.go @@ -0,0 +1,143 @@ +// Copyright 2023 OnMetal 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 handler + +import ( + "context" + "fmt" + + "github.com/onmetal/onmetal-api-net/utils/expectations" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/util/workqueue" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +var observeExpectationsForControllerLog = ctrl.Log.WithName("eventhandler").WithName("observeExpectationsForController") + +type observeExpectationsForController struct { + controllerType client.Object + expectations *expectations.Expectations + + groupKind schema.GroupKind + + mapper meta.RESTMapper +} + +func ObserveExpectationsForController( + scheme *runtime.Scheme, + mapper meta.RESTMapper, + controllerType client.Object, + expectations *expectations.Expectations, +) handler.EventHandler { + o := &observeExpectationsForController{ + controllerType: controllerType, + expectations: expectations, + mapper: mapper, + } + if err := o.parseControllerTypeGroupKind(scheme); err != nil { + panic(err) + } + return o +} + +func (o *observeExpectationsForController) parseControllerTypeGroupKind(scheme *runtime.Scheme) error { + gvk, err := apiutil.GVKForObject(o.controllerType, scheme) + if err != nil { + return err + } + + o.groupKind = gvk.GroupKind() + return nil +} + +func (o *observeExpectationsForController) getControllerKey(object metav1.Object) (*client.ObjectKey, error) { + ctrl := metav1.GetControllerOf(object) + if ctrl == nil { + return nil, nil + } + + ctrlGV, err := schema.ParseGroupVersion(ctrl.APIVersion) + if err != nil { + return nil, fmt.Errorf("error parsing controller APIVersion: %w", err) + } + + if ctrl.Kind != o.groupKind.Kind || ctrlGV.Group != o.groupKind.Group { + return nil, nil + } + + key := client.ObjectKey{Name: ctrl.Name} + + mapping, err := o.mapper.RESTMapping(o.groupKind, ctrlGV.Version) + if err != nil { + return nil, fmt.Errorf("error retrieving rest mapping: %w", err) + } + if mapping.Scope.Name() != meta.RESTScopeNameRoot { + key.Namespace = object.GetNamespace() + } + + return &key, nil +} + +func (o *observeExpectationsForController) delete(obj client.Object) { + ctrlKey, err := o.getControllerKey(obj) + if err != nil { + observeExpectationsForControllerLog.Error(err, "Error getting controller key") + return + } + if ctrlKey == nil { + return + } + + o.expectations.DeletionObserved(*ctrlKey, client.ObjectKeyFromObject(obj)) +} + +func (o *observeExpectationsForController) add(obj client.Object) { + if !obj.GetDeletionTimestamp().IsZero() { + o.delete(obj) + return + } + + ctrlKey, err := o.getControllerKey(obj) + if err != nil { + observeExpectationsForControllerLog.Error(err, "Error getting controller key") + return + } + if ctrlKey == nil { + return + } + o.expectations.CreationObserved(*ctrlKey, client.ObjectKeyFromObject(obj)) +} + +func (o *observeExpectationsForController) Create(_ context.Context, evt event.CreateEvent, _ workqueue.RateLimitingInterface) { + o.add(evt.Object) +} + +func (o *observeExpectationsForController) Update(_ context.Context, _ event.UpdateEvent, _ workqueue.RateLimitingInterface) { +} + +func (o *observeExpectationsForController) Delete(_ context.Context, evt event.DeleteEvent, _ workqueue.RateLimitingInterface) { + o.delete(evt.Object) +} + +func (o *observeExpectationsForController) Generic(_ context.Context, evt event.GenericEvent, _ workqueue.RateLimitingInterface) { + o.add(evt.Object) +} diff --git a/utils/handler/sourceaware.go b/utils/handler/sourceaware.go new file mode 100644 index 00000000..2e6cff40 --- /dev/null +++ b/utils/handler/sourceaware.go @@ -0,0 +1,167 @@ +// Copyright 2023 OnMetal 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 handler + +import ( + "context" + "fmt" + + utilapi "github.com/onmetal/onmetal-api-net/utils/api" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/client-go/util/workqueue" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/handler" +) + +var log = ctrl.Log.WithName("eventhandler").WithName("enqueueRequestForSource") + +type SourceAwareSystem struct { + utilapi.SourceAwareSystem +} + +func NewSourceAwareSystem(system utilapi.SourceAwareSystem) *SourceAwareSystem { + return &SourceAwareSystem{ + system, + } +} + +func (s *SourceAwareSystem) EnqueueRequestForSource(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) handler.EventHandler { + gvk, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + err = fmt.Errorf("error determining source kind: %w", err) + panic(err) + } + + return &enqueueRequestForSource{ + SourceAwareSystem: s.SourceAwareSystem, + gvk: gvk, + mapper: mapper, + } +} + +type enqueueRequestForSource struct { + utilapi.SourceAwareSystem + gvk schema.GroupVersionKind + mapper meta.RESTMapper +} + +func EnqueueRequestForSource(scheme *runtime.Scheme, mapper meta.RESTMapper, sourceObj client.Object) handler.EventHandler { + gvk, err := apiutil.GVKForObject(sourceObj, scheme) + if err != nil { + err = fmt.Errorf("error determining source kind: %w", err) + panic(err) + } + + return &enqueueRequestForSource{ + gvk: gvk, + mapper: mapper, + } +} + +func (e *enqueueRequestForSource) getLabels() (namespaceLabel, nameLabel string, err error) { + mapping, err := e.mapper.RESTMapping(e.gvk.GroupKind(), e.gvk.Version) + if err != nil { + return "", "", err + } + + if mapping.Scope.Name() == meta.RESTScopeNameNamespace { + namespaceLabel = e.SourceNamespaceLabel(e.gvk.Kind) + } + nameLabel = e.SourceNameLabel(e.gvk.Kind) + return namespaceLabel, nameLabel, nil +} + +func (e *enqueueRequestForSource) addRequests( + obj client.Object, + namespaceLabel, nameLabel string, + reqs sets.Set[ctrl.Request], +) { + var namespace string + if namespaceLabel != "" { + var ok bool + namespace, ok = obj.GetLabels()[namespaceLabel] + if !ok { + return + } + } + + name, ok := obj.GetLabels()[nameLabel] + if !ok { + return + } + + reqs.Insert(ctrl.Request{NamespacedName: client.ObjectKey{Namespace: namespace, Name: name}}) +} + +func (e *enqueueRequestForSource) enqueueRequests(reqs sets.Set[ctrl.Request], queue workqueue.RateLimitingInterface) { + for req := range reqs { + queue.Add(req) + } +} + +func (e *enqueueRequestForSource) Create(ctx context.Context, evt event.CreateEvent, queue workqueue.RateLimitingInterface) { + namespaceLabel, nameLabel, err := e.getLabels() + if err != nil { + log.Error(err, "Error getting labels") + return + } + + reqs := sets.New[ctrl.Request]() + e.addRequests(evt.Object, namespaceLabel, nameLabel, reqs) + e.enqueueRequests(reqs, queue) +} + +func (e *enqueueRequestForSource) Update(ctx context.Context, evt event.UpdateEvent, queue workqueue.RateLimitingInterface) { + namespaceLabel, nameLabel, err := e.getLabels() + if err != nil { + log.Error(err, "Error getting labels") + return + } + + reqs := sets.New[ctrl.Request]() + e.addRequests(evt.ObjectOld, namespaceLabel, nameLabel, reqs) + e.addRequests(evt.ObjectNew, namespaceLabel, nameLabel, reqs) + e.enqueueRequests(reqs, queue) +} + +func (e *enqueueRequestForSource) Delete(ctx context.Context, evt event.DeleteEvent, queue workqueue.RateLimitingInterface) { + namespaceLabel, nameLabel, err := e.getLabels() + if err != nil { + log.Error(err, "Error getting labels") + return + } + + reqs := sets.New[ctrl.Request]() + e.addRequests(evt.Object, namespaceLabel, nameLabel, reqs) + e.enqueueRequests(reqs, queue) +} + +func (e *enqueueRequestForSource) Generic(ctx context.Context, evt event.GenericEvent, queue workqueue.RateLimitingInterface) { + namespaceLabel, nameLabel, err := e.getLabels() + if err != nil { + log.Error(err, "Error getting labels") + return + } + + reqs := sets.New[ctrl.Request]() + e.addRequests(evt.Object, namespaceLabel, nameLabel, reqs) + e.enqueueRequests(reqs, queue) +} diff --git a/utils/hash/hash.go b/utils/hash/hash.go new file mode 100644 index 00000000..999ba745 --- /dev/null +++ b/utils/hash/hash.go @@ -0,0 +1,41 @@ +// Copyright 2023 OnMetal 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 hash + +import ( + "encoding/binary" + "fmt" + "hash/fnv" + + "k8s.io/apimachinery/pkg/util/rand" +) + +// ComputeWithCollisionCount computes a hash including an optional collision count of the given data bytes. +func ComputeWithCollisionCount(collisionCount *int32, data ...[]byte) string { + h := fnv.New32a() + + for _, p := range data { + _, _ = h.Write(p) + } + + // Add collisionCount in the hash if it exists + if collisionCount != nil { + collisionCountBytes := make([]byte, 8) + binary.LittleEndian.PutUint32(collisionCountBytes, uint32(*collisionCount)) + _, _ = h.Write(collisionCountBytes) + } + + return rand.SafeEncodeString(fmt.Sprint(h.Sum32())) +} diff --git a/utils/iterator/iterator.go b/utils/iterator/iterator.go new file mode 100644 index 00000000..fdfc0afa --- /dev/null +++ b/utils/iterator/iterator.go @@ -0,0 +1,99 @@ +// Copyright 2023 OnMetal 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 iterator + +func OfSlice[S ~[]E, E any](s S) func(yield func(E) bool) bool { + return func(yield func(E) bool) bool { + for _, e := range s { + if !yield(e) { + return false + } + } + return true + } +} + +func OfSliceRef[S ~[]E, E any](s S) func(yield func(*E) bool) bool { + return func(yield func(*E) bool) bool { + for i := range s { + e := &s[i] + if !yield(e) { + return false + } + } + return true + } +} + +func Map[I ~func(yield func(E) bool) bool, E, F any](it I, f func(E) F) func(yield func(F) bool) bool { + return func(yield func(F) bool) bool { + return it(func(e E) bool { + return yield(f(e)) + }) + } +} + +func Fold[I ~func(yield func(E) bool) bool, A, E any](it I, acc A, f func(A, E) A) A { + it(func(e E) bool { + acc = f(acc, e) + return true + }) + return acc +} + +func Next[I ~func(yield func(E) bool) bool, E any](it I) (E, bool) { + var ( + res E + ok bool + ) + it(func(e E) bool { + res = e + ok = true + return false + }) + return res, ok +} + +func Reduce[I ~func(yield func(E) bool) bool, E any](it I, f func(E, E) E) E { + acc, ok := Next(it) + if !ok { + panic("iterator.Reduce: empty iterator") + } + it(func(e E) bool { + acc = f(acc, e) + return true + }) + return acc +} + +func Concat[I ~func(yield func(E) bool) bool, E any](is ...I) func(yield func(E) bool) bool { + return func(yield func(E) bool) bool { + for _, i := range is { + if !i(yield) { + return false + } + } + return true + } +} + +func CollectSlice[I ~func(yield func(E) bool) bool, E any](it I) []E { + var res []E + it(func(e E) bool { + res = append(res, e) + return true + }) + return res +} diff --git a/utils/netip/netip.go b/utils/netip/netip.go new file mode 100644 index 00000000..6a4b4460 --- /dev/null +++ b/utils/netip/netip.go @@ -0,0 +1,44 @@ +// Copyright 2023 OnMetal 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 netip + +import ( + "fmt" + "math" + "math/big" + "net/netip" +) + +func PrefixSize(p netip.Prefix) int64 { + ones, bits := p.Bits(), p.Addr().BitLen() + if bits == 32 && (bits-ones) >= 31 || bits == 128 && (bits-ones) >= 127 { + return 0 + } + // this checks that we are not overflowing an int64 + if bits-ones >= 63 { + return math.MaxInt64 + } + return int64(1) << uint(bits-ones) +} + +func AddOffsetAddress(address netip.Addr, offset uint64) (netip.Addr, error) { + addressBig := big.NewInt(0).SetBytes(address.AsSlice()) + r := big.NewInt(0).Add(addressBig, big.NewInt(int64(offset))) + addr, ok := netip.AddrFromSlice(r.Bytes()) + if !ok { + return netip.Addr{}, fmt.Errorf("invalid address %v", r.Bytes()) + } + return addr, nil +} diff --git a/utils/slots/slots.go b/utils/slots/slots.go new file mode 100644 index 00000000..97e28c01 --- /dev/null +++ b/utils/slots/slots.go @@ -0,0 +1,186 @@ +// Copyright 2023 OnMetal 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 slots + +import ( + "fmt" + "math/rand" + "sync" + + "github.com/bits-and-blooms/bitset" +) + +type Slots struct { + mu sync.RWMutex + + count int + set *bitset.BitSet + strategy NextClearStrategy +} + +type randomNextClearStrategyWithOffset struct { + offset int +} + +func (s randomNextClearStrategyWithOffset) NextClear(set *bitset.BitSet) (int, bool) { + subLen := int(set.Len()) - s.offset + start := rand.Intn(subLen) + for i := 0; i < subLen; i++ { + idx := s.offset + ((start + i) % subLen) + if !set.Test(uint(idx)) { + return idx, true + } + } + + start = rand.Intn(s.offset) + for i := 0; i < s.offset; i++ { + idx := s.offset + ((start + i) % s.offset) + if !set.Test(uint(idx)) { + return idx, true + } + } + return 0, false +} + +type NextClearStrategy interface { + NextClear(set *bitset.BitSet) (int, bool) +} + +type Options struct { + Offset int +} + +func (o *Options) ApplyOptions(opts []Option) *Options { + for _, opt := range opts { + opt.ApplyTo(o) + } + return o +} + +type Option interface { + ApplyTo(opts *Options) +} + +type WithOffset int + +func (o WithOffset) ApplyTo(opts *Options) { + opts.Offset = int(o) +} + +func New(len int, opts ...Option) *Slots { + if len < 0 { + panic("slots.New: cannot provide negative length") + } + + o := (&Options{}).ApplyOptions(opts) + + return &Slots{ + count: 0, + set: bitset.New(uint(len)), + strategy: randomNextClearStrategyWithOffset{offset: o.Offset}, + } +} + +func (s *Slots) Reset() { + s.mu.Lock() + defer s.mu.Unlock() + + s.count = 0 + s.set.ClearAll() +} + +func (s *Slots) Allocate(index int) (bool, error) { + s.mu.Lock() + defer s.mu.Unlock() + + if index < 0 || index >= int(s.set.Len()) { + return false, fmt.Errorf("index %d out of range [0,%d]", index, s.set.Len()) + } + + if s.set.Test(uint(index)) { + return false, nil + } + + s.set.Set(uint(index)) + s.count++ + return true, nil +} + +func (s *Slots) AllocateNext() (int, bool, error) { + s.mu.Lock() + defer s.mu.Unlock() + + if s.count >= int(s.set.Len()) { + return 0, false, nil + } + + idx, ok := s.strategy.NextClear(s.set) + if !ok { + return 0, false, nil + } + + s.set.Set(uint(idx)) + s.count++ + return idx, true, nil +} + +// Release releases an index. Releasing an unallocated or out-of-range index is considered a no-op. +func (s *Slots) Release(index int) error { + s.mu.Lock() + defer s.mu.Unlock() + + if index < 0 { + return nil + } + + if !s.set.Test(uint(index)) { + return nil + } + + s.set.Clear(uint(index)) + s.count-- + return nil +} + +func (s *Slots) Has(index int) bool { + s.mu.RLock() + defer s.mu.RUnlock() + + if index < 0 { + return false + } + return s.set.Test(uint(index)) +} + +func (s *Slots) Iterate(f func(int) bool) bool { + s.mu.RLock() + defer s.mu.RUnlock() + + for i := uint(0); i < s.set.Len(); i++ { + if s.set.Test(i) { + if !f(int(i)) { + return false + } + } + } + return true +} + +func (s *Slots) Free() int { + s.mu.RLock() + defer s.mu.RUnlock() + + return int(s.set.Len()) - s.count +} diff --git a/utils/testing/testing.go b/utils/testing/testing.go new file mode 100644 index 00000000..2ef95cc9 --- /dev/null +++ b/utils/testing/testing.go @@ -0,0 +1,132 @@ +// Copyright 2023 OnMetal 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 testing + +import ( + "fmt" + "reflect" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega/format" + "github.com/onsi/gomega/types" +) + +type asRef struct { + matcher types.GomegaMatcher +} + +func (a *asRef) toRef(actual any) any { + rv := reflect.ValueOf(actual) + pv := reflect.New(rv.Type()) + pv.Elem().Set(rv) + return pv.Interface() +} + +func (a *asRef) Match(actual any) (success bool, err error) { + return a.matcher.Match(a.toRef(actual)) +} + +func (a *asRef) FailureMessage(actual any) (message string) { + return a.matcher.FailureMessage(a.toRef(actual)) +} + +func (a *asRef) NegatedFailureMessage(actual any) (message string) { + return a.matcher.NegatedFailureMessage(a.toRef(actual)) +} + +func AsRef(matcher types.GomegaMatcher) types.GomegaMatcher { + return &asRef{matcher: matcher} +} + +type capture struct { + vType reflect.Type + intoV reflect.Value + matcher types.GomegaMatcher +} + +func (c *capture) Match(actual any) (success bool, err error) { + actualV := reflect.ValueOf(actual) + if !actualV.CanConvert(c.vType) { + return false, fmt.Errorf("cannot convert %T to %s", actual, c.vType) + } + + success, err = c.matcher.Match(actual) + if success { + c.intoV.Elem().Set(actualV.Convert(c.vType)) + } + return success, err +} + +func (c *capture) FailureMessage(actual any) (message string) { + return c.matcher.FailureMessage(actual) +} + +func (c *capture) NegatedFailureMessage(actual any) (message string) { + return c.matcher.NegatedFailureMessage(actual) +} + +func Capture(into any, matcher types.GomegaMatcher) types.GomegaMatcher { + intoV := reflect.ValueOf(into) + if intoV.Kind() != reflect.Pointer { + ginkgo.Fail(fmt.Sprintf("value %T is not a pointer-type", intoV)) + } + + return &capture{ + vType: intoV.Type().Elem(), + intoV: intoV, + matcher: matcher, + } +} + +type haveKeysWithValues[K comparable, V any] struct { + keysWithValues map[K]V +} + +func (k *haveKeysWithValues[K, V]) Match(actualV any) (success bool, err error) { + actual, ok := actualV.(map[K]V) + if !ok { + var ( + k K + v V + ) + return false, fmt.Errorf("HaveKeysWithValues matcher requires a map[%T]%T. Got:\n%s", k, v, format.Object(actual, 1)) + } + + if len(actual) < len(k.keysWithValues) { + return false, nil + } + + for k, v := range k.keysWithValues { + aV, ok := actual[k] + if !ok || !reflect.DeepEqual(aV, v) { + return false, nil + } + } + return true, nil +} + +func (k *haveKeysWithValues[K, V]) FailureMessage(actual any) (message string) { + return format.Message(actual, "to contain keys with values", k.keysWithValues) +} + +func (k *haveKeysWithValues[K, V]) NegatedFailureMessage(actual any) (message string) { + return format.Message(actual, "not to contain keys with values", k.keysWithValues) +} + +func HaveKeysWithValues[M ~map[K]V, K comparable, V any](keysWithValues M) types.GomegaMatcher { + return &haveKeysWithValues[K, V]{ + keysWithValues: keysWithValues, + } +}