Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions api/v1alpha7/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func TestFuzzyConversion(t *testing.T) {
// None of the following identityRef fields have ever been set in v1alpha7
identityRef.Region = ""
},
func(portOpts *infrav1.PortOpts, c fuzz.Continue) {
c.FuzzNoCustom(portOpts)

// None of the following PortOpts fields have ever been set in v1alpha7
portOpts.Subports = nil
},
}

return slices.Concat(v1alpha7FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())
Expand Down
59 changes: 59 additions & 0 deletions api/v1alpha7/types_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ package v1alpha7

import (
"errors"
unsafe "unsafe"

apiconversion "k8s.io/apimachinery/pkg/conversion"

infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
v1beta1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/conversioncommon"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
)
Expand Down Expand Up @@ -426,6 +428,35 @@ func Convert_v1alpha7_PortOpts_To_v1beta1_PortOpts(in *PortOpts, out *infrav1.Po
}
}

if in.Network != nil {
in, out := &in.Network, &out.Network
*out = new(v1beta1.NetworkParam)
if err := Convert_v1alpha7_NetworkFilter_To_v1beta1_NetworkParam(*in, *out, s); err != nil {
return err
}
} else {
out.Network = nil
}
if err := optional.Convert_string_To_optional_String(&in.NameSuffix, &out.NameSuffix, s); err != nil {
return err
}
if err := optional.Convert_string_To_optional_String(&in.Description, &out.Description, s); err != nil {
return err
}

if in.FixedIPs != nil {
in, out := &in.FixedIPs, &out.FixedIPs
*out = make([]v1beta1.FixedIP, len(*in))
for i := range *in {
if err := Convert_v1alpha7_FixedIP_To_v1beta1_FixedIP(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.FixedIPs = nil
}
out.Tags = *(*[]string)(unsafe.Pointer(&in.Tags))

return nil
}

Expand Down Expand Up @@ -482,6 +513,34 @@ func Convert_v1beta1_PortOpts_To_v1alpha7_PortOpts(in *infrav1.PortOpts, out *Po
}
}

if in.Network != nil {
in, out := &in.Network, &out.Network
*out = new(NetworkFilter)
if err := Convert_v1beta1_NetworkParam_To_v1alpha7_NetworkFilter(*in, *out, s); err != nil {
return err
}
} else {
out.Network = nil
}
if err := optional.Convert_optional_String_To_string(&in.Description, &out.Description, s); err != nil {
return err
}
if err := optional.Convert_optional_String_To_string(&in.NameSuffix, &out.NameSuffix, s); err != nil {
return err
}
if in.FixedIPs != nil {
in, out := &in.FixedIPs, &out.FixedIPs
*out = make([]FixedIP, len(*in))
for i := range *in {
if err := Convert_v1beta1_FixedIP_To_v1alpha7_FixedIP(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.FixedIPs = nil
}
out.Tags = *(*[]string)(unsafe.Pointer(&in.Tags))

return nil
}

Expand Down
63 changes: 7 additions & 56 deletions api/v1alpha7/zz_generated.conversion.go

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

75 changes: 68 additions & 7 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type AllocationPool struct {
End string `json:"end"`
}

type PortOpts struct {
type CommonPortOpts struct {
// Network is a query for an openstack network that the port will be created or discovered on.
// This will fail if the query returns more than one network.
// +optional
Expand Down Expand Up @@ -320,13 +320,41 @@ type PortOpts struct {
// +optional
Tags []string `json:"tags,omitempty"`

ResolvedPortSpecFields `json:",inline"`
}

// PortOpts defines port parameters.
type PortOpts struct {
// Trunk specifies whether trunking is enabled at the port level. If not
// provided the value is inherited from the machine, or false for a
// bastion host.
// +optional
Trunk *bool `json:"trunk,omitempty"`

ResolvedPortSpecFields `json:",inline"`
// Subports is a list of port specifications that will be created as
// subports of the trunk.
// +optional
// +listType=atomic
Subports []SubportOpts `json:"subports,omitempty"`

CommonPortOpts `json:",inline"`
}

// SubportOpts defines a trunk subport.
type SubportOpts struct {
// SegmentationID is the segmentation ID of the subport. E.g. VLAN ID.
// +required
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=4094
SegmentationID int `json:"segmentationID"`

// SegmentationType is the segmentation type of the subport. E.g. "vlan".
// +required
// +kubebuilder:validation:Enum=vlan;flat
SegmentationType string `json:"segmentationType"`

// Port contains parameters of the port associated with this subport
CommonPortOpts `json:",inline"`
}

// ResolvePortSpecFields is a convenience struct containing all fields of a
Expand Down Expand Up @@ -393,7 +421,7 @@ type ResolvedPortSpecFields struct {
}

// ResolvedPortSpec is a PortOpts with all contained references fully resolved.
type ResolvedPortSpec struct {
type CommonResolvedPortSpec struct {
// Name is the name of the port.
Name string `json:"name"`

Expand All @@ -408,10 +436,6 @@ type ResolvedPortSpec struct {
// +optional
Tags []string `json:"tags,omitempty"`

// Trunk specifies whether trunking is enabled at the port level.
// +optional
Trunk optional.Bool `json:"trunk,omitempty"`

// FixedIPs is a list of pairs of subnet and/or IP address to assign to the port. If specified, these must be subnets of the port's network.
// +optional
// +listType=atomic
Expand All @@ -425,10 +449,47 @@ type ResolvedPortSpec struct {
ResolvedPortSpecFields `json:",inline"`
}

type ResolvedPortSpec struct {
// Trunk specifies whether trunking is enabled at the port level.
// +optional
Trunk optional.Bool `json:"trunk,omitempty"`

// Subports is a list of resolved port specifications that will be created as
// subports of the trunk.
// +optional
// +listType=atomic
Subports []ResolvedSubportSpec `json:"subports,omitempty"`

CommonResolvedPortSpec `json:",inline"`
}

// ResolvedSubportSpec is a SubportOpts with all contained references fully resolved.
type ResolvedSubportSpec struct {
// SegmentationID is the segmentation ID of the subport. E.g. VLAN ID.
SegmentationID int `json:"segmentationID"`

// SegmentationType is the segmentation type of the subport. E.g. "vlan".
SegmentationType string `json:"segmentationType"`

// Port is a PortOpts with all contained references fully resolved. This is
// essentially port which is used as subport in trunk
CommonResolvedPortSpec `json:",inline"`
}

type PortStatus struct {
// ID is the unique identifier of the port.
// +required
ID string `json:"id"`

// Subports is the list of port IDs which intended to be trunk sub-ports
// +optional
Subports []SubPortStatus `json:"subports,omitempty"`
}

type SubPortStatus struct {
// ID is the unique identifier of the trunk sub-port.
// +required
ID string `json:"id"`
}

type BindingProfile struct {
Expand Down
Loading