Skip to content

Commit b5670f9

Browse files
committed
⚠️ Rename OSM.ports[*].DisablePortSecurity to EnablePortSecurity
Invert the polarity of the port security field on PortOpts and ResolvedPortSpecFields for consistency with positive-polarity boolean conventions.
1 parent 6037fb9 commit b5670f9

32 files changed

Lines changed: 287 additions & 122 deletions

api/v1beta1/conversion.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,27 @@ func ConvertAllTagsFrom(neutronTags *FilterByNeutronTags, tags, tagsAny, notTags
588588
*notTags = JoinTags(neutronTags.NotTags)
589589
*notTagsAny = JoinTags(neutronTags.NotTagsAny)
590590
}
591+
592+
func Convert_v1beta1_ResolvedPortSpecFields_To_v1beta2_ResolvedPortSpecFields(in *ResolvedPortSpecFields, out *infrav1.ResolvedPortSpecFields, s apiconversion.Scope) error {
593+
if err := autoConvert_v1beta1_ResolvedPortSpecFields_To_v1beta2_ResolvedPortSpecFields(in, out, s); err != nil {
594+
return err
595+
}
596+
597+
if in.DisablePortSecurity != nil {
598+
out.EnablePortSecurity = ptr.To(!*in.DisablePortSecurity)
599+
}
600+
601+
return nil
602+
}
603+
604+
func Convert_v1beta2_ResolvedPortSpecFields_To_v1beta1_ResolvedPortSpecFields(in *infrav1.ResolvedPortSpecFields, out *ResolvedPortSpecFields, s apiconversion.Scope) error {
605+
if err := autoConvert_v1beta2_ResolvedPortSpecFields_To_v1beta1_ResolvedPortSpecFields(in, out, s); err != nil {
606+
return err
607+
}
608+
609+
if in.EnablePortSecurity != nil {
610+
out.DisablePortSecurity = ptr.To(!*in.EnablePortSecurity)
611+
}
612+
613+
return nil
614+
}

api/v1beta1/conversion_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,3 +1512,51 @@ func TestOpenStackCluster_RoundTrip_ExternalNetwork(t *testing.T) {
15121512
})
15131513
}
15141514
}
1515+
1516+
func TestResolvedPortSpecFields_RoundTrip_PortSecurity(t *testing.T) {
1517+
tests := []struct {
1518+
name string
1519+
in ResolvedPortSpecFields
1520+
expectedEnablePS *bool
1521+
}{
1522+
{
1523+
name: "DisablePortSecurity explicitly true",
1524+
in: ResolvedPortSpecFields{
1525+
DisablePortSecurity: ptr.To(true),
1526+
},
1527+
expectedEnablePS: ptr.To(false), // disable=true → enable=false
1528+
},
1529+
{
1530+
name: "DisablePortSecurity explicitly false",
1531+
in: ResolvedPortSpecFields{
1532+
DisablePortSecurity: ptr.To(false),
1533+
},
1534+
expectedEnablePS: ptr.To(true), // disable=false → enable=true
1535+
},
1536+
{
1537+
name: "DisablePortSecurity unset — EnablePortSecurity stays nil",
1538+
in: ResolvedPortSpecFields{},
1539+
expectedEnablePS: nil, // unset stays unset, inherits from network level
1540+
},
1541+
}
1542+
1543+
for _, tt := range tests {
1544+
t.Run(tt.name, func(t *testing.T) {
1545+
g := NewWithT(t)
1546+
1547+
// --- Convert to v1beta2 ---
1548+
out := &infrav1.ResolvedPortSpecFields{}
1549+
g.Expect(Convert_v1beta1_ResolvedPortSpecFields_To_v1beta2_ResolvedPortSpecFields(&tt.in, out, nil)).To(Succeed())
1550+
1551+
// --- Verify intermediate v1beta2 state ---
1552+
g.Expect(out.EnablePortSecurity).To(Equal(tt.expectedEnablePS))
1553+
1554+
// --- Convert back to v1beta1 ---
1555+
restored := &ResolvedPortSpecFields{}
1556+
g.Expect(Convert_v1beta2_ResolvedPortSpecFields_To_v1beta1_ResolvedPortSpecFields(out, restored, nil)).To(Succeed())
1557+
1558+
// --- Verify full round-trip ---
1559+
g.Expect(restored.DisablePortSecurity).To(Equal(tt.in.DisablePortSecurity))
1560+
})
1561+
}
1562+
}

api/v1beta1/zz_generated.conversion.go

Lines changed: 110 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/openstackcluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ type OpenStackClusterSpec struct {
8484
// external networks unless EnableExternalNetwork is also set to false.
8585
//
8686
// If ExternalNetwork is not defined and there are no external networks
87-
// the controller will proceed as though EnableExternalNetwork was set to true.
87+
// the controller will proceed as though EnableExternalNetwork was set to false.
8888
// +optional
8989
ExternalNetwork *NetworkParam `json:"externalNetwork,omitempty"`
9090

api/v1beta2/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ type ResolvedPortSpecFields struct {
424424
// +optional
425425
Profile *BindingProfile `json:"profile,omitempty"`
426426

427-
// disablePortSecurity enables or disables the port security when set.
427+
// enablePortSecurity enables or disables the port security when set.
428428
// When not set, it takes the value of the corresponding field at the network level.
429429
// +optional
430-
DisablePortSecurity *bool `json:"disablePortSecurity,omitempty"`
430+
EnablePortSecurity *bool `json:"enablePortSecurity,omitempty"`
431431

432432
// propagateUplinkStatus enables or disables the propagate uplink status on the port.
433433
// +optional

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)