|
| 1 | +/* |
| 2 | +Copyright 2021. Netris, Inc. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
| 24 | +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. |
| 25 | + |
| 26 | +// InventoryProfileSpec defines the desired state of InventoryProfile |
| 27 | +type InventoryProfileSpec struct { |
| 28 | + Description string `json:"description,omitempty"` |
| 29 | + |
| 30 | + Timezone string `json:"timezone,omitempty"` |
| 31 | + |
| 32 | + AllowSSHFromIPv4 []string `json:"allowSshFromIpv4"` |
| 33 | + AllowSSHFromIPv6 []string `json:"allowSshFromIpv6,omitempty"` |
| 34 | + NTPServers []NTPServer `json:"ntpServers,omitempty"` |
| 35 | + DNSServers []DNSServer `json:"dnsServers,omitempty"` |
| 36 | + CustomRules []InventoryProfileCustomRule `json:"customRules,omitempty"` |
| 37 | +} |
| 38 | + |
| 39 | +type InventoryProfileCustomRule struct { |
| 40 | + // +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01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-9]?\d)){3}))|:)))(%.+)?(\/([0-9]{1,2}|1[01][0-9]|12[0-8]))?$)` |
| 41 | + SrcSubnet string `json:"srcSubnet"` |
| 42 | + |
| 43 | + // +kubebuilder:validation:Pattern=`^()([1-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[1-5])$` |
| 44 | + SrcPort string `json:"srcPort,omitempty"` |
| 45 | + |
| 46 | + // +kubebuilder:validation:Pattern=`^()([1-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[1-5])$` |
| 47 | + DstPort string `json:"dstPort,omitempty"` |
| 48 | + |
| 49 | + // +kubebuilder:validation:Enum=tcp;udp;any |
| 50 | + Protocol string `json:"protocol"` |
| 51 | +} |
| 52 | + |
| 53 | +// +kubebuilder:validation:Pattern=`((^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([0-9]|[1-5][0-9]|6[0-4]))?$)|(^(.{1,22}$)?(([a-z0-9-]{1,63}\.)?(xn--+)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$))` |
| 54 | +type NTPServer string |
| 55 | + |
| 56 | +// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([0-9]|[1-5][0-9]|6[0-4]))?$)` |
| 57 | +type DNSServer string |
| 58 | + |
| 59 | +// InventoryProfileStatus defines the observed state of InventoryProfile |
| 60 | +type InventoryProfileStatus struct { |
| 61 | + Status string `json:"status,omitempty"` |
| 62 | + Message string `json:"message,omitempty"` |
| 63 | + IPv4List string `json:"ipv4List,omitempty"` |
| 64 | + IPv6List string `json:"ipv6List,omitempty"` |
| 65 | + NTPServers string `json:"ntpServers,omitempty"` |
| 66 | + DNSServers string `json:"dnsServers,omitempty"` |
| 67 | + CustomRules string `json:"customRules,omitempty"` |
| 68 | +} |
| 69 | + |
| 70 | +//+kubebuilder:object:root=true |
| 71 | +//+kubebuilder:subresource:status |
| 72 | +// +kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description` |
| 73 | +// +kubebuilder:printcolumn:name="Timezone",type=string,JSONPath=`.spec.timezone` |
| 74 | +// +kubebuilder:printcolumn:name="NTPServers",type=string,JSONPath=`.status.ntpServers` |
| 75 | +// +kubebuilder:printcolumn:name="DNSServers",type=string,JSONPath=`.status.dnsServers` |
| 76 | +// +kubebuilder:printcolumn:name="IPv4List",type=string,JSONPath=`.status.ipv4List`,priority=1 |
| 77 | +// +kubebuilder:printcolumn:name="IPv6List",type=string,JSONPath=`.status.ipv6List`,priority=1 |
| 78 | +// +kubebuilder:printcolumn:name="CustomRules",type=string,JSONPath=`.status.customRules`,priority=1 |
| 79 | +// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status` |
| 80 | +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` |
| 81 | + |
| 82 | +// InventoryProfile is the Schema for the inventoryprofiles API |
| 83 | +type InventoryProfile struct { |
| 84 | + metav1.TypeMeta `json:",inline"` |
| 85 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 86 | + |
| 87 | + Spec InventoryProfileSpec `json:"spec,omitempty"` |
| 88 | + Status InventoryProfileStatus `json:"status,omitempty"` |
| 89 | +} |
| 90 | + |
| 91 | +//+kubebuilder:object:root=true |
| 92 | + |
| 93 | +// InventoryProfileList contains a list of InventoryProfile |
| 94 | +type InventoryProfileList struct { |
| 95 | + metav1.TypeMeta `json:",inline"` |
| 96 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 97 | + Items []InventoryProfile `json:"items"` |
| 98 | +} |
| 99 | + |
| 100 | +func init() { |
| 101 | + SchemeBuilder.Register(&InventoryProfile{}, &InventoryProfileList{}) |
| 102 | +} |
0 commit comments