|
| 1 | +/* |
| 2 | +Copyright 2024 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +// BuiltinsName is the name of the builtin variable. |
| 20 | +const BuiltinsName = "builtin" |
| 21 | + |
| 22 | +// Builtins represents builtin variables exposed through patches. |
| 23 | +type Builtins struct { |
| 24 | + Cluster *ClusterBuiltins `json:"cluster,omitempty"` |
| 25 | + ControlPlane *ControlPlaneBuiltins `json:"controlPlane,omitempty"` |
| 26 | + MachineDeployment *MachineDeploymentBuiltins `json:"machineDeployment,omitempty"` |
| 27 | + MachinePool *MachinePoolBuiltins `json:"machinePool,omitempty"` |
| 28 | +} |
| 29 | + |
| 30 | +// ClusterBuiltins represents builtin cluster variables. |
| 31 | +type ClusterBuiltins struct { |
| 32 | + // Name is the name of the cluster. |
| 33 | + Name string `json:"name,omitempty"` |
| 34 | + |
| 35 | + // Namespace is the namespace of the cluster. |
| 36 | + Namespace string `json:"namespace,omitempty"` |
| 37 | + |
| 38 | + // Topology represents the cluster topology variables. |
| 39 | + Topology *ClusterTopologyBuiltins `json:"topology,omitempty"` |
| 40 | + |
| 41 | + // Network represents the cluster network variables. |
| 42 | + Network *ClusterNetworkBuiltins `json:"network,omitempty"` |
| 43 | +} |
| 44 | + |
| 45 | +// ClusterTopologyBuiltins represents builtin cluster topology variables. |
| 46 | +type ClusterTopologyBuiltins struct { |
| 47 | + // Version is the Kubernetes version of the Cluster. |
| 48 | + // NOTE: Please note that this version might temporarily differ from the version |
| 49 | + // of the ControlPlane or workers while an upgrade process is being orchestrated. |
| 50 | + Version string `json:"version,omitempty"` |
| 51 | + |
| 52 | + // Class is the name of the ClusterClass of the Cluster. |
| 53 | + Class string `json:"class,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// ClusterNetworkBuiltins represents builtin cluster network variables. |
| 57 | +type ClusterNetworkBuiltins struct { |
| 58 | + // ServiceDomain is the domain name for services. |
| 59 | + ServiceDomain *string `json:"serviceDomain,omitempty"` |
| 60 | + // Services is the network ranges from which service VIPs are allocated. |
| 61 | + Services []string `json:"services,omitempty"` |
| 62 | + // Pods is the network ranges from which Pod networks are allocated. |
| 63 | + Pods []string `json:"pods,omitempty"` |
| 64 | + // IPFamily is the IPFamily the Cluster is operating in. One of Invalid, IPv4, IPv6, DualStack. |
| 65 | + // Note: IPFamily is not a concept in Kubernetes. It was originally introduced in CAPI for CAPD. |
| 66 | + // IPFamily may be dropped in a future release. More details at https://github.com/kubernetes-sigs/cluster-api/issues/7521 |
| 67 | + IPFamily string `json:"ipFamily,omitempty"` |
| 68 | +} |
| 69 | + |
| 70 | +// ControlPlaneBuiltins represents builtin ControlPlane variables. |
| 71 | +// NOTE: These variables are only set for templates belonging to the ControlPlane object. |
| 72 | +type ControlPlaneBuiltins struct { |
| 73 | + // Version is the Kubernetes version of the ControlPlane object. |
| 74 | + // NOTE: Please note that this version is the version we are currently reconciling towards. |
| 75 | + // It can differ from the current version of the ControlPlane while an upgrade process is |
| 76 | + // being orchestrated. |
| 77 | + Version string `json:"version,omitempty"` |
| 78 | + |
| 79 | + // Name is the name of the ControlPlane, |
| 80 | + // to which the current template belongs to. |
| 81 | + Name string `json:"name,omitempty"` |
| 82 | + |
| 83 | + // Replicas is the value of the replicas field of the ControlPlane object. |
| 84 | + Replicas *int64 `json:"replicas,omitempty"` |
| 85 | + |
| 86 | + // MachineTemplate is the value of the .spec.machineTemplate field of the ControlPlane object. |
| 87 | + MachineTemplate *ControlPlaneMachineTemplateBuiltins `json:"machineTemplate,omitempty"` |
| 88 | +} |
| 89 | + |
| 90 | +// ControlPlaneMachineTemplateBuiltins is the value of the .spec.machineTemplate field of the ControlPlane object. |
| 91 | +type ControlPlaneMachineTemplateBuiltins struct { |
| 92 | + // InfrastructureRef is the value of the infrastructureRef field of ControlPlane.spec.machineTemplate. |
| 93 | + InfrastructureRef ControlPlaneMachineTemplateInfrastructureRefBuiltins `json:"infrastructureRef,omitempty"` |
| 94 | +} |
| 95 | + |
| 96 | +// ControlPlaneMachineTemplateInfrastructureRefBuiltins is the value of the infrastructureRef field of |
| 97 | +// ControlPlane.spec.machineTemplate. |
| 98 | +type ControlPlaneMachineTemplateInfrastructureRefBuiltins struct { |
| 99 | + // Name of the infrastructureRef. |
| 100 | + Name string `json:"name,omitempty"` |
| 101 | +} |
| 102 | + |
| 103 | +// MachineDeploymentBuiltins represents builtin MachineDeployment variables. |
| 104 | +// NOTE: These variables are only set for templates belonging to a MachineDeployment. |
| 105 | +type MachineDeploymentBuiltins struct { |
| 106 | + // Version is the Kubernetes version of the MachineDeployment, |
| 107 | + // to which the current template belongs to. |
| 108 | + // NOTE: Please note that this version is the version we are currently reconciling towards. |
| 109 | + // It can differ from the current version of the MachineDeployment machines while an upgrade process is |
| 110 | + // being orchestrated. |
| 111 | + Version string `json:"version,omitempty"` |
| 112 | + |
| 113 | + // Class is the class name of the MachineDeployment, |
| 114 | + // to which the current template belongs to. |
| 115 | + Class string `json:"class,omitempty"` |
| 116 | + |
| 117 | + // Name is the name of the MachineDeployment, |
| 118 | + // to which the current template belongs to. |
| 119 | + Name string `json:"name,omitempty"` |
| 120 | + |
| 121 | + // TopologyName is the topology name of the MachineDeployment, |
| 122 | + // to which the current template belongs to. |
| 123 | + TopologyName string `json:"topologyName,omitempty"` |
| 124 | + |
| 125 | + // Replicas is the value of the replicas field of the MachineDeployment, |
| 126 | + // to which the current template belongs to. |
| 127 | + Replicas *int64 `json:"replicas,omitempty"` |
| 128 | + |
| 129 | + // Bootstrap is the value of the .spec.template.spec.bootstrap field of the MachineDeployment. |
| 130 | + Bootstrap *MachineBootstrapBuiltins `json:"bootstrap,omitempty"` |
| 131 | + |
| 132 | + // InfrastructureRef is the value of the .spec.template.spec.infrastructureRef field of the MachineDeployment. |
| 133 | + InfrastructureRef *MachineInfrastructureRefBuiltins `json:"infrastructureRef,omitempty"` |
| 134 | +} |
| 135 | + |
| 136 | +// MachinePoolBuiltins represents builtin MachinePool variables. |
| 137 | +// NOTE: These variables are only set for templates belonging to a MachinePool. |
| 138 | +type MachinePoolBuiltins struct { |
| 139 | + // Version is the Kubernetes version of the MachinePool, |
| 140 | + // to which the current template belongs to. |
| 141 | + // NOTE: Please note that this version is the version we are currently reconciling towards. |
| 142 | + // It can differ from the current version of the MachinePool machines while an upgrade process is |
| 143 | + // being orchestrated. |
| 144 | + Version string `json:"version,omitempty"` |
| 145 | + |
| 146 | + // Class is the class name of the MachinePool, |
| 147 | + // to which the current template belongs to. |
| 148 | + Class string `json:"class,omitempty"` |
| 149 | + |
| 150 | + // Name is the name of the MachinePool, |
| 151 | + // to which the current template belongs to. |
| 152 | + Name string `json:"name,omitempty"` |
| 153 | + |
| 154 | + // TopologyName is the topology name of the MachinePool, |
| 155 | + // to which the current template belongs to. |
| 156 | + TopologyName string `json:"topologyName,omitempty"` |
| 157 | + |
| 158 | + // Replicas is the value of the replicas field of the MachinePool, |
| 159 | + // to which the current template belongs to. |
| 160 | + Replicas *int64 `json:"replicas,omitempty"` |
| 161 | + |
| 162 | + // Bootstrap is the value of the .spec.template.spec.bootstrap field of the MachinePool. |
| 163 | + Bootstrap *MachineBootstrapBuiltins `json:"bootstrap,omitempty"` |
| 164 | + |
| 165 | + // InfrastructureRef is the value of the .spec.template.spec.infrastructureRef field of the MachinePool. |
| 166 | + InfrastructureRef *MachineInfrastructureRefBuiltins `json:"infrastructureRef,omitempty"` |
| 167 | +} |
| 168 | + |
| 169 | +// MachineBootstrapBuiltins is the value of the .spec.template.spec.bootstrap field |
| 170 | +// of the MachineDeployment or MachinePool. |
| 171 | +type MachineBootstrapBuiltins struct { |
| 172 | + // ConfigRef is the value of the .spec.template.spec.bootstrap.configRef field of the MachineDeployment. |
| 173 | + ConfigRef *MachineBootstrapConfigRefBuiltins `json:"configRef,omitempty"` |
| 174 | +} |
| 175 | + |
| 176 | +// MachineBootstrapConfigRefBuiltins is the value of the .spec.template.spec.bootstrap.configRef |
| 177 | +// field of the MachineDeployment or MachinePool. |
| 178 | +type MachineBootstrapConfigRefBuiltins struct { |
| 179 | + // Name of the bootstrap.configRef. |
| 180 | + Name string `json:"name,omitempty"` |
| 181 | +} |
| 182 | + |
| 183 | +// MachineInfrastructureRefBuiltins is the value of the .spec.template.spec.infrastructureRef field |
| 184 | +// of the MachineDeployment or MachinePool. |
| 185 | +type MachineInfrastructureRefBuiltins struct { |
| 186 | + // Name of the infrastructureRef. |
| 187 | + Name string `json:"name,omitempty"` |
| 188 | +} |
0 commit comments