|
| 1 | +// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package v1alpha1 |
| 5 | + |
| 6 | +import ( |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | +) |
| 9 | + |
| 10 | +// SyslogSpec defines the desired state of Syslog |
| 11 | +type SyslogSpec struct { |
| 12 | + // DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace. |
| 13 | + // Immutable. |
| 14 | + // +required |
| 15 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable" |
| 16 | + DeviceRef LocalObjectReference `json:"deviceRef"` |
| 17 | + |
| 18 | + // ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface. |
| 19 | + // This reference is used to link the Interface to its provider-specific configuration. |
| 20 | + // +optional |
| 21 | + ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"` |
| 22 | + |
| 23 | + // Servers is a list of remote log servers to which the device will send logs. |
| 24 | + // +required |
| 25 | + // +kubebuilder:validation:MinItems=1 |
| 26 | + // +kubebuilder:validation:MaxItems=16 |
| 27 | + Servers []LogServer `json:"servers"` |
| 28 | + |
| 29 | + // Facilities is a list of log facilities to configure on the device. |
| 30 | + // +required |
| 31 | + // +kubebuilder:validation:MinItems=1 |
| 32 | + // +kubebuilder:validation:MaxItems=64 |
| 33 | + Facilities []LogFacility `json:"facilities"` |
| 34 | +} |
| 35 | + |
| 36 | +type LogServer struct { |
| 37 | + // IP address or hostname of the remote log server |
| 38 | + // +required |
| 39 | + // +kubebuilder:validation:MinLength=1 |
| 40 | + // +kubebuilder:validation:MaxLength=253 |
| 41 | + Address string `json:"address"` |
| 42 | + |
| 43 | + // The servity level of the log messages sent to the server. |
| 44 | + // +required |
| 45 | + Severity Severity `json:"severity"` |
| 46 | + |
| 47 | + // The name of the vrf used to reach the log server. |
| 48 | + // +required |
| 49 | + // +kubebuilder:validation:MinLength=1 |
| 50 | + // +kubebuilder:validation:MaxLength=63 |
| 51 | + VrfName string `json:"vrfName"` |
| 52 | + |
| 53 | + // The destination port number for syslog UDP messages to |
| 54 | + // the server. The default is 514. |
| 55 | + // +optional |
| 56 | + // +kubebuilder:default=514 |
| 57 | + Port int32 `json:"port"` |
| 58 | +} |
| 59 | + |
| 60 | +type LogFacility struct { |
| 61 | + // The name of the log facility. |
| 62 | + // +required |
| 63 | + // +kubebuilder:validation:MinLength=1 |
| 64 | + // +kubebuilder:validation:MaxLength=63 |
| 65 | + Name string `json:"name"` |
| 66 | + |
| 67 | + // The severity level of the log messages for this facility. |
| 68 | + // +required |
| 69 | + Severity Severity `json:"severity"` |
| 70 | +} |
| 71 | + |
| 72 | +// Severity represents the severity level of a log message. |
| 73 | +// +kubebuilder:validation:Enum=Debug;Info;Notice;Warning;Error;Critical;Alert;Emergency |
| 74 | +type Severity string |
| 75 | + |
| 76 | +const ( |
| 77 | + SeverityDebug Severity = "Debug" |
| 78 | + SeverityInfo Severity = "Info" |
| 79 | + SeverityNotice Severity = "Notice" |
| 80 | + SeverityWarning Severity = "Warning" |
| 81 | + SeverityError Severity = "Error" |
| 82 | + SeverityCritical Severity = "Critical" |
| 83 | + SeverityAlert Severity = "Alert" |
| 84 | + SeverityEmergency Severity = "Emergency" |
| 85 | +) |
| 86 | + |
| 87 | +// SyslogStatus defines the observed state of Syslog. |
| 88 | +type SyslogStatus struct { |
| 89 | + // The conditions are a list of status objects that describe the state of the Banner. |
| 90 | + //+listType=map |
| 91 | + //+listMapKey=type |
| 92 | + //+patchStrategy=merge |
| 93 | + //+patchMergeKey=type |
| 94 | + //+optional |
| 95 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 96 | +} |
| 97 | + |
| 98 | +// +kubebuilder:object:root=true |
| 99 | +// +kubebuilder:subresource:status |
| 100 | +// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceName` |
| 101 | +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` |
| 102 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 103 | + |
| 104 | +// Syslog is the Schema for the syslogs API |
| 105 | +type Syslog struct { |
| 106 | + metav1.TypeMeta `json:",inline"` |
| 107 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 108 | + |
| 109 | + // Specification of the desired state of the resource. |
| 110 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 111 | + // +required |
| 112 | + Spec SyslogSpec `json:"spec,omitempty"` |
| 113 | + |
| 114 | + // Status of the resource. This is set and updated automatically. |
| 115 | + // Read-only. |
| 116 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status |
| 117 | + // +optional |
| 118 | + Status SyslogStatus `json:"status,omitempty,omitzero"` |
| 119 | +} |
| 120 | + |
| 121 | +// +kubebuilder:object:root=true |
| 122 | + |
| 123 | +// SyslogList contains a list of Syslog |
| 124 | +type SyslogList struct { |
| 125 | + metav1.TypeMeta `json:",inline"` |
| 126 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 127 | + Items []Syslog `json:"items"` |
| 128 | +} |
| 129 | + |
| 130 | +func init() { |
| 131 | + SchemeBuilder.Register(&Syslog{}, &SyslogList{}) |
| 132 | +} |
0 commit comments