|
| 1 | +/* |
| 2 | +Copyright 2022. |
| 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 v1beta1 |
| 18 | + |
| 19 | +import ( |
| 20 | + v1 "k8s.io/api/core/v1" |
| 21 | + networkingv1 "k8s.io/api/networking/v1" |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | +) |
| 24 | + |
| 25 | +// FlagdSpec defines the desired state of Flagd |
| 26 | +type FlagdSpec struct { |
| 27 | + // Replicas defines the number of replicas to create for the service. |
| 28 | + // Default: 1 |
| 29 | + // +optional |
| 30 | + // +kubebuilder:default=1 |
| 31 | + Replicas *int32 `json:"replicas,omitempty"` |
| 32 | + |
| 33 | + // ServiceType represents the type of Service to create. |
| 34 | + // Must be one of: ClusterIP, NodePort, LoadBalancer, and ExternalName. |
| 35 | + // Default: ClusterIP |
| 36 | + // +optional |
| 37 | + // +kubebuilder:default=ClusterIP |
| 38 | + // +kubebuilder:validation:Enum:=ClusterIP;NodePort;LoadBalancer;ExternalName |
| 39 | + ServiceType v1.ServiceType `json:"serviceType,omitempty"` |
| 40 | + |
| 41 | + // ServiceAccountName the service account name for the flagd deployment |
| 42 | + // +optional |
| 43 | + ServiceAccountName string `json:"serviceAccountName,omitempty"` |
| 44 | + |
| 45 | + // FeatureFlagSource references to a FeatureFlagSource from which the created flagd instance retrieves |
| 46 | + // the feature flag configurations |
| 47 | + FeatureFlagSource string `json:"featureFlagSource"` |
| 48 | + |
| 49 | + // Ingress |
| 50 | + // +optional |
| 51 | + Ingress IngressSpec `json:"ingress"` |
| 52 | +} |
| 53 | + |
| 54 | +// IngressSpec defines the options to be used when deploying the ingress for flagd |
| 55 | +type IngressSpec struct { |
| 56 | + // Enabled enables/disables the ingress for flagd |
| 57 | + Enabled bool `json:"enabled,omitempty"` |
| 58 | + |
| 59 | + // Annotations the annotations to be added to the ingress |
| 60 | + // +optional |
| 61 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 62 | + |
| 63 | + // Hosts list of hosts to be added to the ingress |
| 64 | + // +optional |
| 65 | + Hosts []string `json:"hosts,omitempty"` |
| 66 | + |
| 67 | + // TLS configuration for the ingress |
| 68 | + TLS []networkingv1.IngressTLS `json:"tls,omitempty"` |
| 69 | + |
| 70 | + // IngressClassName defines the name if the ingress class to be used for flagd |
| 71 | + // +optional |
| 72 | + IngressClassName *string `json:"ingressClassName,omitempty"` |
| 73 | + |
| 74 | + // PathType is the path type to be used for the ingress rules |
| 75 | + // +optional |
| 76 | + PathType networkingv1.PathType `json:"pathType,omitempty"` |
| 77 | + |
| 78 | + // FlagdPath is the path to be used for accessing the flagd flag evaluation API |
| 79 | + // +optional |
| 80 | + FlagdPath string `json:"flagdPath,omitempty"` |
| 81 | + |
| 82 | + // OFREPPath is the path to be used for accessing the OFREP API |
| 83 | + // +optional |
| 84 | + OFREPPath string `json:"ofrepPath"` |
| 85 | + |
| 86 | + // SyncPath is the path to be used for accessing the sync API |
| 87 | + // +optional |
| 88 | + SyncPath string `json:"syncPath"` |
| 89 | +} |
| 90 | + |
| 91 | +// FlagdStatus defines the observed state of Flagd |
| 92 | +type FlagdStatus struct { |
| 93 | +} |
| 94 | + |
| 95 | +//+kubebuilder:object:root=true |
| 96 | +//+kubebuilder:subresource:status |
| 97 | + |
| 98 | +// Flagd is the Schema for the flagds API |
| 99 | +type Flagd struct { |
| 100 | + metav1.TypeMeta `json:",inline"` |
| 101 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 102 | + |
| 103 | + Spec FlagdSpec `json:"spec,omitempty"` |
| 104 | + Status FlagdStatus `json:"status,omitempty"` |
| 105 | +} |
| 106 | + |
| 107 | +//+kubebuilder:object:root=true |
| 108 | + |
| 109 | +// FlagdList contains a list of Flagd |
| 110 | +type FlagdList struct { |
| 111 | + metav1.TypeMeta `json:",inline"` |
| 112 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 113 | + Items []Flagd `json:"items"` |
| 114 | +} |
| 115 | + |
| 116 | +func init() { |
| 117 | + SchemeBuilder.Register(&Flagd{}, &FlagdList{}) |
| 118 | +} |
0 commit comments