Skip to content

Commit 7800925

Browse files
committed
fix: nits from review
1 parent 3881216 commit 7800925

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

docs/content/customization/nutanix/machine-details.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,18 @@ spec:
111111
vcpusPerSocket: 1
112112
```
113113

114-
### (Optional) Use Image template
114+
### (Optional) Using templates for VM Image lookup:
115+
116+
Users can set format look up the image for a VM, It will be ignored if an explicit image is set.
117+
Supports substitutions for `{{.BaseOS}}` and `{{.K8sVersion}}` with the base OS and
118+
kubernetes version, respectively. The BaseOS will be the value in BaseOS and the K8sVersion
119+
is the value in the Machine `.spec.version`, with the v prefix removed.
120+
This is effectively the defined by the packages produced by kubernetes/release without v as a
121+
prefix: 1.13.0, 1.12.5-mybuild.1, or 1.17.3. For example, the default
122+
image format of `{{.BaseOS}}-?{{.K8sVersion}}-*` and `BaseOS` as "rhel-8.10" will end up
123+
searching for images that match the pattern rhel-8.10-1.30.5-* for a
124+
Machine that is targeting Kubernetes version `v1.30.5`. See
125+
also: https://golang.org/pkg/text/template/
115126

116127
```yaml
117128
apiVersion: cluster.x-k8s.io/v1beta1

pkg/handlers/nutanix/mutation/machinedetails/inject.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package machinedetails
55

66
import (
77
"context"
8+
"errors"
89
"slices"
910

1011
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -32,6 +33,8 @@ type nutanixMachineDetailsPatchHandler struct {
3233
patchSelector clusterv1.PatchSelector
3334
}
3435

36+
var ErrNoImageOrImageLookupSet = errors.New("image or image lookup must be set")
37+
3538
func newNutanixMachineDetailsPatchHandler(
3639
metaVariableName string,
3740
variableFieldPath []string,
@@ -98,6 +101,8 @@ func (h *nutanixMachineDetailsPatchHandler) Mutate(
98101
spec.Image = nutanixMachineDetailsVar.Image.DeepCopy()
99102
} else if nutanixMachineDetailsVar.ImageLookup != nil {
100103
spec.ImageLookup = nutanixMachineDetailsVar.ImageLookup.DeepCopy()
104+
} else {
105+
return ErrNoImageOrImageLookupSet
101106
}
102107

103108
spec.VCPUSockets = nutanixMachineDetailsVar.VCPUSockets

test/e2e/data/shared/v1beta1-capx/metadata.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
1111
kind: Metadata
1212
releaseSeries:
13-
- major: 1
14-
minor: 5
15-
contract: v1beta1
1613
- major: 1
1714
minor: 6
1815
contract: v1beta1

0 commit comments

Comments
 (0)