Skip to content

Commit 2bd6779

Browse files
committed
Add templateReference logic in Metal3DataTemplate
1 parent 841ab05 commit 2bd6779

5 files changed

+24
-0
lines changed

api/v1alpha4/metal3data_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ type Metal3DataSpec struct {
3232
// Index stores the index value of this instance in the Metal3DataTemplate.
3333
Index int `json:"index,omitempty"`
3434

35+
// TemplateReference refers to the Template the Metal3MachineTemplate refers to.
36+
// It can be matched against the key or it may also point to the name of the template
37+
// Metal3Data refers to
38+
TemplateReference string `json:"templateReference,omitempty"`
39+
3540
// MetaData points to the rendered MetaData secret.
3641
MetaData *corev1.SecretReference `json:"metaData,omitempty"`
3742

api/v1alpha4/metal3datatemplate_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,11 @@ type Metal3DataTemplateSpec struct {
431431
// +kubebuilder:validation:MinLength=1
432432
ClusterName string `json:"clusterName"`
433433

434+
// TemplateReference refers to the Template the Metal3MachineTemplate refers to.
435+
// It can be matched against the key or it may also point to the name of the template
436+
// Metal3Data refers to
437+
TemplateReference string `json:"templateReference,omitempty"`
438+
434439
//MetaData contains the information needed to generate the metadata secret
435440
MetaData *MetaData `json:"metaData,omitempty"`
436441

baremetal/metal3datatemplate_manager.go

+8
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ func (m *DataTemplateManager) getIndexes(ctx context.Context) (map[int]string, e
135135
continue
136136
}
137137

138+
// Match TemplateReference
139+
if dataObject.Spec.TemplateReference == "" && m.DataTemplate.Spec.TemplateReference != dataObject.Spec.Template.Name {
140+
continue
141+
}
142+
if dataObject.Spec.TemplateReference != "" && m.DataTemplate.Spec.TemplateReference != dataObject.Spec.TemplateReference {
143+
continue
144+
}
145+
138146
// Get the claim Name, if unset use empty string, to still record the
139147
// index being used, to avoid conflicts
140148
claimName := ""

config/crd/bases/infrastructure.cluster.x-k8s.io_metal3datas.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ spec:
113113
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
114114
type: string
115115
type: object
116+
templateReference:
117+
description: TemplateReference refers to the Template the Metal3MachineTemplate refers to. It can be matched against the key or it may also point to the name of the template Metal3Data refers to
118+
type: string
116119
required:
117120
- claim
118121
- template

config/crd/bases/infrastructure.cluster.x-k8s.io_metal3datatemplates.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ spec:
704704
type: string
705705
type: object
706706
type: object
707+
templateReference:
708+
description: TemplateReference refers to the Template the Metal3MachineTemplate refers to. It can be matched against the key or it may also point to the name of the template Metal3Data refers to
709+
type: string
707710
required:
708711
- clusterName
709712
type: object

0 commit comments

Comments
 (0)