Skip to content

Commit 68297f5

Browse files
Standardize administrative state using AdminState enum across resources
This patch harmonizes the API for setting a administrative state on resources using the AdminState enumeration and introduces this field for protocols (BGP, OSPF, ISIS, PIM) and system level services (NTP, DNS).
1 parent 042d175 commit 68297f5

45 files changed

Lines changed: 294 additions & 62 deletions

File tree

Some content is hidden

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

‎api/cisco/nx/v1alpha1/bordergateway_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ type BorderGatewaySpec struct {
1717
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
1818
DeviceRef v1alpha1.LocalObjectReference `json:"deviceRef"`
1919

20+
// AdminState indicates whether the BorderGateway instance is administratively up or down.
21+
// +optional
22+
// +kubebuilder:default=Up
23+
AdminState v1alpha1.AdminState `json:"adminState,omitempty"`
24+
2025
// MultisiteID is the identifier for the multisite border gateway.
2126
// +required
2227
// +kubebuilder:validation:Minimum=1

‎api/cisco/nx/v1alpha1/vpcdomain_types.go‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package v1alpha1
66
import (
77
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
88

9-
corev1 "github.com/ironcore-dev/network-operator/api/core/v1alpha1"
9+
"github.com/ironcore-dev/network-operator/api/core/v1alpha1"
1010
)
1111

1212
// VPCDomainSpec defines the desired state of a vPC domain (Virtual Port Channel Domain)
@@ -15,7 +15,7 @@ type VPCDomainSpec struct {
1515
// Immutable.
1616
// +required
1717
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
18-
DeviceRef corev1.LocalObjectReference `json:"deviceRef"`
18+
DeviceRef v1alpha1.LocalObjectReference `json:"deviceRef"`
1919

2020
// DomainID is the vPC domain ID (1-1000).
2121
// This uniquely identifies the vPC domain and must match on both peer switches.
@@ -27,8 +27,9 @@ type VPCDomainSpec struct {
2727

2828
// AdminState is the administrative state of the vPC domain (enabled/disabled).
2929
// When disabled, the vPC domain is administratively shut down.
30-
// +required
31-
AdminState AdminState `json:"adminState"`
30+
// +optional
31+
// +kubebuilder:default=Up
32+
AdminState v1alpha1.AdminState `json:"adminState"`
3233

3334
// RolePriority is the role priority for this vPC domain (1-65535).
3435
// The switch with the lower role priority becomes the operational primary.
@@ -67,17 +68,6 @@ type VPCDomainSpec struct {
6768
Peer Peer `json:"peer"`
6869
}
6970

70-
// AdminState represents the administrative state of the peer-link connection (Up/Down).
71-
// +kubebuilder:validation:Enum=Up;Down
72-
type AdminState string
73-
74-
const (
75-
// AdminStateUp indicates the connection to the peer is administratively enabled.
76-
AdminStateUp AdminState = "Up"
77-
// AdminStateDown indicates the connection to the peer is administratively disabled.
78-
AdminStateDown AdminState = "Down"
79-
)
80-
8171
// Enabled represents a simple enabled/disabled configuration.
8272
type Enabled struct {
8373
// Enabled indicates whether a configuration property is administratively enabled (true) or disabled (false).
@@ -88,14 +78,15 @@ type Enabled struct {
8878
// Peer defines settings to configure peer settings
8979
type Peer struct {
9080
// AdminState defines the administrative state of the peer-link.
91-
// +required
92-
AdminState AdminState `json:"adminState"`
81+
// +optional
82+
// +kubebuilder:default=Up
83+
AdminState v1alpha1.AdminState `json:"adminState"`
9384

9485
// InterfaceRef is a reference to an Interface resource and identifies the interface to be used as the vPC domain's peer-link.
9586
// This interface carries control and data traffic between the two vPC domain peers.
9687
// It is usually dedicated port-channel, but it can also be a single physical interface.
9788
// +required
98-
InterfaceRef corev1.LocalObjectReference `json:"interfaceRef,omitempty"`
89+
InterfaceRef v1alpha1.LocalObjectReference `json:"interfaceRef,omitempty"`
9990

10091
// KeepAlive defines the out-of-band keepalive configuration.
10192
// +required
@@ -145,7 +136,7 @@ type KeepAlive struct {
145136
// If specified, the switch sends keepalive packets throughout this VRF.
146137
// If omitted, the management VRF is used.
147138
// +optional
148-
VRFRef *corev1.LocalObjectReference `json:"vrfRef,omitempty"`
139+
VRFRef *v1alpha1.LocalObjectReference `json:"vrfRef,omitempty"`
149140
}
150141

151142
// AutoRecovery holds settings to automatically restore vPC domain's operation after detecting

‎api/core/v1alpha1/bgp_peer_types.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ type BGPPeerSpec struct {
2121
// +optional
2222
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2323

24+
// AdminState indicates whether this BGP peer is administratively up or down.
25+
// When Down, the BGP session with this peer is administratively shut down.
26+
// +optional
27+
// +kubebuilder:default=Up
28+
AdminState AdminState `json:"adminState,omitempty"`
29+
2430
// Address is the IPv4 address of the BGP peer.
2531
// +required
2632
// +kubebuilder:validation:Format=ipv4

‎api/core/v1alpha1/bgp_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ type BGPSpec struct {
2121
// +optional
2222
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2323

24+
// AdminState indicates whether this BGP router is administratively up or down.
25+
// +optional
26+
// +kubebuilder:default=Up
27+
AdminState AdminState `json:"adminState,omitempty"`
28+
2429
// ASNumber is the autonomous system number (ASN) for the BGP router.
2530
// Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
2631
// +required

‎api/core/v1alpha1/dns_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type DNSSpec struct {
2020
// +optional
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

23+
// AdminState indicates whether DNS is administratively up or down.
24+
// +optional
25+
// +kubebuilder:default=Up
26+
AdminState AdminState `json:"adminState,omitempty"`
27+
2328
// Default domain name that the device uses to complete unqualified hostnames.
2429
// +required
2530
// +kubebuilder:validation:MinLength=1

‎api/core/v1alpha1/interface_types.go‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ type InterfaceSpec struct {
4343
Name string `json:"name"`
4444

4545
// AdminState indicates whether the interface is administratively up or down.
46-
// +required
46+
// +optional
47+
// +kubebuilder:default=Up
4748
AdminState AdminState `json:"adminState"`
4849

4950
// Description provides a human-readable description of the interface.
@@ -95,14 +96,16 @@ type InterfaceSpec struct {
9596
BFD *BFD `json:"bfd,omitempty"`
9697
}
9798

98-
// AdminState represents the administrative state of the interface.
99+
// AdminState represents the administrative state of a resource.
100+
// This type is used across multiple resources including interfaces, protocols (BGP, OSPF, ISIS, PIM),
101+
// and system services (NTP, DNS) to indicate whether these are administratively enabled or disabled.
99102
// +kubebuilder:validation:Enum=Up;Down
100103
type AdminState string
101104

102105
const (
103-
// AdminStateUp indicates that the interface is administratively set up.
106+
// AdminStateUp indicates that the resource is administratively enabled.
104107
AdminStateUp AdminState = "Up"
105-
// AdminStateDown indicates that the interface is administratively set down.
108+
// AdminStateDown indicates that the resource is administratively disabled.
106109
AdminStateDown AdminState = "Down"
107110
)
108111

‎api/core/v1alpha1/isis_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type ISISSpec struct {
2020
// +optional
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

23+
// AdminState indicates whether the ISIS instance is administratively up or down.
24+
// +optional
25+
// +kubebuilder:default=Up
26+
AdminState AdminState `json:"adminState,omitempty"`
27+
2328
// Instance is the name of the ISIS instance.
2429
// +required
2530
// +kubebuilder:validation:MinLength=1

‎api/core/v1alpha1/ntp_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type NTPSpec struct {
2020
// +optional
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

23+
// AdminState indicates whether NTP is administratively up or down.
24+
// +optional
25+
// +kubebuilder:default=Up
26+
AdminState AdminState `json:"adminState,omitempty"`
27+
2328
// Source interface for all NTP traffic.
2429
// +required
2530
// +kubebuilder:validation:MinLength=1

‎api/core/v1alpha1/ospf_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type OSPFSpec struct {
2020
// +optional
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

23+
// AdminState indicates whether the OSPF instance is administratively up or down.
24+
// +optional
25+
// +kubebuilder:default=Up
26+
AdminState AdminState `json:"adminState,omitempty"`
27+
2328
// Instance is the process tag of the OSPF instance.
2429
// +required
2530
// +kubebuilder:validation:MinLength=1

‎api/core/v1alpha1/pim_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type PIMSpec struct {
2020
// +optional
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

23+
// AdminState indicates whether the PIM instance is administratively up or down.
24+
// +optional
25+
// +kubebuilder:default=Up
26+
AdminState AdminState `json:"adminState,omitempty"`
27+
2328
// RendezvousPoints defines the list of rendezvous points for sparse mode multicast.
2429
// +optional
2530
// +listType=map

0 commit comments

Comments
 (0)