Add types and generated code for CRDs
[ovn4nfv-k8s-plugin.git] / pkg / apis / k8s / v1alpha1 / network_types.go
1 package v1alpha1
2
3 import (
4         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5 )
6
7 // EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
8 // NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.
9
10 // NetworkSpec defines the desired state of Network
11 // +k8s:openapi-gen=true
12 type NetworkSpec struct {
13         // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
14         // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
15         // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
16         CniType     string     `json:"cniType"`
17         Ipv4Subnets []IpSubnet `json:"ipv4Subnets"`
18         Ipv6Subnets []IpSubnet `json:"ipv6Subnets,omitempty"`
19         DNS         DnsSpec    `json:"dns,omitempty"`
20         Routes      []Route    `json:"routes,omitempty"`
21 }
22
23 type IpSubnet struct {
24         Name       string `json:"name"`
25         Subnet     string `json:"subnet"`
26         Gateway    string `json:"gateway,omitempty"`
27         ExcludeIps string `json:"excludeIps,omitempty"`
28 }
29
30 type Route struct {
31         Dst string `json:"dst"`
32         GW  string `json:"gw,omitempty"`
33 }
34
35 type DnsSpec struct {
36         Nameservers []string `json:"nameservers,omitempty"`
37         Domain      string   `json:"domain,omitempty"`
38         Search      []string `json:"search,omitempty"`
39         Options     []string `json:"options,omitempty"`
40 }
41
42 const (
43         //Created indicates the status of success
44         Created = "Created"
45         //Indicates internal Irrecoverable Error
46         InternalError = "InternalError"
47 )
48
49 // NetworkStatus defines the observed state of Network
50 // +k8s:openapi-gen=true
51 type NetworkStatus struct {
52         // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
53         // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
54         // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
55         State string `json:"state"` // Indicates if Network is in "created" state
56 }
57
58 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
59
60 // Network is the Schema for the networks API
61 // +k8s:openapi-gen=true
62 // +kubebuilder:subresource:status
63 type Network struct {
64         metav1.TypeMeta   `json:",inline"`
65         metav1.ObjectMeta `json:"metadata,omitempty"`
66
67         Spec   NetworkSpec   `json:"spec,omitempty"`
68         Status NetworkStatus `json:"status,omitempty"`
69 }
70
71 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
72
73 // NetworkList contains a list of Network
74 type NetworkList struct {
75         metav1.TypeMeta `json:",inline"`
76         metav1.ListMeta `json:"metadata,omitempty"`
77         Items           []Network `json:"items"`
78 }
79
80 func init() {
81         SchemeBuilder.Register(&Network{}, &NetworkList{})
82 }