/
eventhubnamespace_types.go
115 lines (94 loc) · 4.28 KB
/
eventhubnamespace_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package v1alpha1
import (
helpers "github.com/Azure/azure-service-operator/pkg/helpers"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// EventhubNamespaceSpec defines the desired state of EventhubNamespace
type EventhubNamespaceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Location string `json:"location"`
Sku EventhubNamespaceSku `json:"sku,omitempty"`
Properties EventhubNamespaceProperties `json:"properties,omitempty"`
// +kubebuilder:validation:Pattern=^[-\w\._\(\)]+$
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
ResourceGroup string `json:"resourceGroup"`
NetworkRule *EventhubNamespaceNetworkRule `json:"networkRule,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// EventhubNamespace is the Schema for the eventhubnamespaces API
// +kubebuilder:resource:shortName=ehns
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message"
type EventhubNamespace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec EventhubNamespaceSpec `json:"spec,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// EventhubNamespaceList contains a list of EventhubNamespace
type EventhubNamespaceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []EventhubNamespace `json:"items"`
}
// EventhubNamespaceSku defines the sku
type EventhubNamespaceSku struct {
Name string `json:"name,omitempty"` //allowedValues "Basic", "Standard"
Tier string `json:"tier,omitempty"` //allowedValues "Basic", "Standard"
Capacity int32 `json:"capacity,omitempty"` //allowedValues 1, 2, 4
}
// EventhubNamespaceProperties defines the namespace properties
type EventhubNamespaceProperties struct {
IsAutoInflateEnabled bool `json:"isAutoInflateEnabled,omitempty"`
MaximumThroughputUnits int32 `json:"maximumThroughputUnits,omitempty"`
KafkaEnabled bool `json:"kafkaEnabled,omitempty"`
}
// EventhubNamespaceNetworkRule defines the namespace network rule
type EventhubNamespaceNetworkRule struct {
DefaultAction DefaultAction `json:"defaultAction,omitempty"`
// VirtualNetworkRules - List VirtualNetwork Rules
VirtualNetworkRules *[]VirtualNetworkRules `json:"virtualNetworkRules,omitempty"`
// IPRules - List of IpRules
IPRules *[]IPRules `json:"ipRules,omitempty"`
}
// DefaultAction defined as a string
type DefaultAction string
const (
// Allow ...
Allow DefaultAction = "Allow"
// Deny ...
Deny DefaultAction = "Deny"
)
type VirtualNetworkRules struct {
// Subnet - Full Resource ID of Virtual Network Subnet
SubnetID string `json:"subnetId,omitempty"`
// IgnoreMissingVnetServiceEndpoint - Value that indicates whether to ignore missing VNet Service Endpoint
IgnoreMissingServiceEndpoint bool `json:"ignoreMissingServiceEndpoint,omitempty"`
}
type IPRules struct {
// IPMask - IPv4 address 1.1.1.1 or CIDR notation 1.1.0.0/24
IPMask *string `json:"ipMask,omitempty"`
}
func init() {
SchemeBuilder.Register(&EventhubNamespace{}, &EventhubNamespaceList{})
}
func (eventhubNamespace *EventhubNamespace) IsSubmitted() bool {
return eventhubNamespace.Status.Provisioning || eventhubNamespace.Status.Provisioned
}
func (eventhubNamespace *EventhubNamespace) HasFinalizer(finalizerName string) bool {
return helpers.ContainsString(eventhubNamespace.ObjectMeta.Finalizers, finalizerName)
}
func (eventhubNamespace *EventhubNamespace) AddFinalizer(finalizerName string) {
eventhubNamespace.ObjectMeta.Finalizers = append(eventhubNamespace.ObjectMeta.Finalizers, finalizerName)
}
func (eventhubNamespace *EventhubNamespace) RemoveFinalizer(finalizerName string) {
eventhubNamespace.ObjectMeta.Finalizers = helpers.RemoveString(eventhubNamespace.ObjectMeta.Finalizers, finalizerName)
}