Skip to content

Commit

Permalink
Enable mac address retrieved from annotations
Browse files Browse the repository at this point in the history
This addresses issue #1208.

Signed-off-by: Florian Haftmann <flha@uhurutec.com>
  • Loading branch information
Florian Haftmann committed Oct 10, 2023
1 parent 07d7eb6 commit 35801fe
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 53 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ func (dst *Metal3DataTemplate) ConvertFrom(srcRaw conversion.Hub) error {
return utilconversion.MarshalData(src, dst)
}

func Convert_v1beta1_NetworkLinkEthernetMac_To_v1alpha5_NetworkLinkEthernetMac(in *v1beta1.NetworkLinkEthernetMac, out *NetworkLinkEthernetMac, s apiconversion.Scope) error {
// fromAnnotation was added with v1betaX.
return autoConvert_v1beta1_NetworkLinkEthernetMac_To_v1alpha5_NetworkLinkEthernetMac(in, out, s)
}

func Convert_v1beta1_NetworkDataIPv6_To_v1alpha5_NetworkDataIPv6(in *v1beta1.NetworkDataIPv6, out *NetworkDataIPv6, s apiconversion.Scope) error {
// fromPoolRef was added with v1beta1.
return autoConvert_v1beta1_NetworkDataIPv6_To_v1alpha5_NetworkDataIPv6(in, out, s)
Expand Down
124 changes: 104 additions & 20 deletions api/v1alpha5/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions api/v1beta1/metal3datatemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ type MetaData struct {
FromAnnotations []MetaDataFromAnnotation `json:"fromAnnotations,omitempty"`
}

// NetworkLinkEthernetMacFromAnnotation contains the information to fetch an annotation
// content, if the label does not exist, it is rendered as empty string.
type NetworkLinkEthernetMacFromAnnotation struct {
// +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost
// Object is the type of the object from which we retrieve the name
Object string `json:"object"`
// Annotation is the key of the Annotation to fetch
Annotation string `json:"annotation"`
}

// NetworkLinkEthernetMac represents the Mac address content.
type NetworkLinkEthernetMac struct {
// String contains the MAC address given as a string
Expand All @@ -201,6 +211,11 @@ type NetworkLinkEthernetMac struct {
// Introspection details from which to fetch the MAC address
// +optional
FromHostInterface *string `json:"fromHostInterface,omitempty"`

// FromAnnotation references an object Annotation to retrieve the
// MAC address from
// +optional
FromAnnotation *NetworkLinkEthernetMacFromAnnotation `json:"fromAnnotation,omitempty"`
}

// NetworkDataLinkEthernet represents an ethernet link object.
Expand Down
20 changes: 20 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 35801fe

Please sign in to comment.