Skip to content

Commit 710a752

Browse files
committed
Trunk type: fix scaffolding issues + minor bugs
1 parent 960bd52 commit 710a752

File tree

82 files changed

+1909
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1909
-41
lines changed

api/v1alpha1/trunk_types.go

Lines changed: 100 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,43 @@ limitations under the License.
1515
*/
1616

1717
package v1alpha1
18+
// TrunkSubportSpec represents a subport to attach to a trunk.
19+
// It maps to gophercloud's trunks.Subport.
20+
type TrunkSubportSpec struct {
21+
// portRef is a reference to the ORC Port that will be attached as a subport.
22+
// +required
23+
PortRef KubernetesNameRef `json:"portRef"`
24+
25+
// segmentationID is the segmentation ID for the subport (e.g. VLAN ID).
26+
// +required
27+
// +kubebuilder:validation:Minimum:=1
28+
// +kubebuilder:validation:Maximum:=4094
29+
SegmentationID int32 `json:"segmentationID"`
30+
31+
// segmentationType is the segmentation type for the subport (e.g. vlan).
32+
// +required
33+
// +kubebuilder:validation:MinLength:=1
34+
// +kubebuilder:validation:MaxLength:=255
35+
SegmentationType string `json:"segmentationType"`
36+
}
37+
38+
// TrunkSubportStatus represents an attached subport on a trunk.
39+
// It maps to gophercloud's trunks.Subport.
40+
type TrunkSubportStatus struct {
41+
// portID is the OpenStack ID of the Port attached as a subport.
42+
// +kubebuilder:validation:MaxLength=1024
43+
// +optional
44+
PortID string `json:"portID,omitempty"`
45+
46+
// segmentationID is the segmentation ID for the subport (e.g. VLAN ID).
47+
// +optional
48+
SegmentationID int32 `json:"segmentationID,omitempty"`
49+
50+
// segmentationType is the segmentation type for the subport (e.g. vlan).
51+
// +kubebuilder:validation:MaxLength=1024
52+
// +optional
53+
SegmentationType string `json:"segmentationType,omitempty"`
54+
}
1855

1956
// TrunkResourceSpec contains the desired state of the resource.
2057
type TrunkResourceSpec struct {
@@ -24,10 +61,8 @@ type TrunkResourceSpec struct {
2461
Name *OpenStackName `json:"name,omitempty"`
2562

2663
// description is a human-readable description for the resource.
27-
// +kubebuilder:validation:MinLength:=1
28-
// +kubebuilder:validation:MaxLength:=255
2964
// +optional
30-
Description *string `json:"description,omitempty"`
65+
Description *NeutronDescription `json:"description,omitempty"`
3166

3267
// portRef is a reference to the ORC Port which this resource is associated with.
3368
// +required
@@ -39,13 +74,30 @@ type TrunkResourceSpec struct {
3974
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="projectRef is immutable"
4075
ProjectRef *KubernetesNameRef `json:"projectRef,omitempty"`
4176

42-
// TODO(scaffolding): Add more types.
43-
// To see what is supported, you can take inspiration from the CreateOpts structure from
44-
// github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks
77+
// adminStateUp is the administrative state of the trunk. If false (down),
78+
// the trunk does not forward packets.
79+
// +optional
80+
AdminStateUp *bool `json:"adminStateUp,omitempty"`
81+
82+
// subports is the list of ports to attach to the trunk.
4583
//
46-
// Until you have implemented mutability for the field, you must add a CEL validation
47-
// preventing the field being modified:
48-
// `// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="<fieldname> is immutable"`
84+
// NOTE: ORC currently does not implement reconcile logic for subport updates
85+
// (Neutron uses dedicated add/remove subport APIs). This field is immutable
86+
// until that behavior is implemented in the controller.
87+
// +optional
88+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="subports is immutable"
89+
// +kubebuilder:validation:MaxItems:=1024
90+
// +listType=atomic
91+
Subports []TrunkSubportSpec `json:"subports,omitempty"`
92+
93+
// tags is a list of Neutron tags to apply to the trunk.
94+
//
95+
// NOTE: ORC does not currently reconcile tag updates for Trunk.
96+
// +kubebuilder:validation:MaxItems:=64
97+
// +listType=set
98+
// +optional
99+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="tags is immutable"
100+
Tags []NeutronTag `json:"tags,omitempty"`
49101
}
50102

51103
// TrunkFilter defines an existing resource by its properties
@@ -56,10 +108,8 @@ type TrunkFilter struct {
56108
Name *OpenStackName `json:"name,omitempty"`
57109

58110
// description of the existing resource
59-
// +kubebuilder:validation:MinLength:=1
60-
// +kubebuilder:validation:MaxLength:=255
61111
// +optional
62-
Description *string `json:"description,omitempty"`
112+
Description *NeutronDescription `json:"description,omitempty"`
63113

64114
// portRef is a reference to the ORC Port which this resource is associated with.
65115
// +optional
@@ -69,9 +119,16 @@ type TrunkFilter struct {
69119
// +optional
70120
ProjectRef *KubernetesNameRef `json:"projectRef,omitempty"`
71121

72-
// TODO(scaffolding): Add more types.
73-
// To see what is supported, you can take inspiration from the ListOpts structure from
74-
// github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks
122+
// status indicates whether the trunk is currently operational. Possible values include
123+
// `ACTIVE', `DOWN', `BUILD', `DEGRADED' or `ERROR'. Plug-ins might define additional values.
124+
// +optional
125+
Status *string `json:"status,omitempty"`
126+
127+
// adminStateUp is the administrative state of the trunk.
128+
// +optional
129+
AdminStateUp *bool `json:"adminStateUp,omitempty"`
130+
131+
FilterByNeutronTags `json:",inline"`
75132
}
76133

77134
// TrunkResourceStatus represents the observed state of the resource.
@@ -96,7 +153,32 @@ type TrunkResourceStatus struct {
96153
// +optional
97154
ProjectID string `json:"projectID,omitempty"`
98155

99-
// TODO(scaffolding): Add more types.
100-
// To see what is supported, you can take inspiration from the Trunk structure from
101-
// github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks
156+
// tenantID is the project owner of the trunk (alias of projectID in some deployments).
157+
// +kubebuilder:validation:MaxLength=1024
158+
// +optional
159+
TenantID string `json:"tenantID,omitempty"`
160+
161+
// status indicates whether the trunk is currently operational.
162+
// +kubebuilder:validation:MaxLength=1024
163+
// +optional
164+
Status string `json:"status,omitempty"`
165+
166+
// tags is the list of tags on the resource.
167+
// +kubebuilder:validation:MaxItems=64
168+
// +kubebuilder:validation:items:MaxLength=1024
169+
// +listType=atomic
170+
// +optional
171+
Tags []string `json:"tags,omitempty"`
172+
173+
NeutronStatusMetadata `json:",inline"`
174+
175+
// adminStateUp is the administrative state of the trunk.
176+
// +optional
177+
AdminStateUp *bool `json:"adminStateUp,omitempty"`
178+
179+
// subports is a list of ports associated with the trunk.
180+
// +kubebuilder:validation:MaxItems=1024
181+
// +listType=atomic
182+
// +optional
183+
Subports []TrunkSubportStatus `json:"subports,omitempty"`
102184
}

api/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)