Skip to content

Commit e9f614d

Browse files
authored
feat: support full sync (#125)
1 parent f14c95e commit e9f614d

File tree

24 files changed

+1518
-31
lines changed

24 files changed

+1518
-31
lines changed

api/adc/types.go

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,54 @@ const (
6060
PassHostRewrite = "rewrite"
6161
)
6262

63+
type Object interface {
64+
GetLabels() map[string]string
65+
}
66+
67+
// +k8s:deepcopy-gen=true
6368
type Metadata struct {
6469
ID string `json:"id,omitempty" yaml:"id,omitempty"`
6570
Name string `json:"name,omitempty" yaml:"name,omitempty"`
6671
Desc string `json:"description,omitempty" yaml:"description,omitempty"`
6772
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
6873
}
6974

75+
func (m *Metadata) GetLabels() map[string]string { return m.Labels }
76+
7077
type Resources struct {
7178
ConsumerGroups []*ConsumerGroup `json:"consumer_groups,omitempty" yaml:"consumer_groups,omitempty"`
7279
Consumers []*Consumer `json:"consumers,omitempty" yaml:"consumers,omitempty"`
73-
GlobalRules Plugins `json:"global_rules,omitempty" yaml:"global_rules,omitempty"`
74-
PluginMetadata Plugins `json:"plugin_metadata,omitempty" yaml:"plugin_metadata,omitempty"`
80+
GlobalRules GlobalRule `json:"global_rules,omitempty" yaml:"global_rules,omitempty"`
81+
PluginMetadata PluginMetadata `json:"plugin_metadata,omitempty" yaml:"plugin_metadata,omitempty"`
7582
Services []*Service `json:"services,omitempty" yaml:"services,omitempty"`
7683
SSLs []*SSL `json:"ssls,omitempty" yaml:"ssls,omitempty"`
7784
}
7885

86+
type GlobalRule Plugins
87+
88+
func (g *GlobalRule) DeepCopy() GlobalRule {
89+
original := Plugins(*g)
90+
copied := original.DeepCopy()
91+
return GlobalRule(copied)
92+
}
93+
94+
type PluginMetadata Plugins
95+
96+
func (p *PluginMetadata) DeepCopy() PluginMetadata {
97+
original := Plugins(*p)
98+
copied := original.DeepCopy()
99+
return PluginMetadata(copied)
100+
}
101+
102+
// +k8s:deepcopy-gen=true
79103
type ConsumerGroup struct {
80104
Metadata `json:",inline" yaml:",inline"`
81105
Consumers []Consumer `json:"consumers,omitempty" yaml:"consumers,omitempty"`
82106
Name string `json:"name" yaml:"name"`
83107
Plugins Plugins `json:"plugins" yaml:"plugins"`
84108
}
85109

110+
// +k8s:deepcopy-gen=true
86111
type Consumer struct {
87112
Credentials []Credential `json:"credentials,omitempty" yaml:"credentials,omitempty"`
88113
Description string `json:"description,omitempty" yaml:"description,omitempty"`
@@ -91,13 +116,15 @@ type Consumer struct {
91116
Username string `json:"username" yaml:"username"`
92117
}
93118

119+
// +k8s:deepcopy-gen=true
94120
type Credential struct {
95121
Metadata `json:",inline" yaml:",inline"`
96122

97-
Config map[string]any `json:"config" yaml:"config"`
98-
Type string `json:"type" yaml:"type"`
123+
Config Plugins `json:"config" yaml:"config"`
124+
Type string `json:"type" yaml:"type"`
99125
}
100126

127+
// +k8s:deepcopy-gen=true
101128
type Service struct {
102129
Metadata `json:",inline" yaml:",inline"`
103130

@@ -110,6 +137,7 @@ type Service struct {
110137
Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"`
111138
}
112139

140+
// +k8s:deepcopy-gen=true
113141
type Route struct {
114142
Metadata `json:",inline" yaml:",inline"`
115143

@@ -131,6 +159,7 @@ type Timeout struct {
131159
Send int `json:"send"`
132160
}
133161

162+
// +k8s:deepcopy-gen=true
134163
type StreamRoute struct {
135164
Description string `json:"description,omitempty"`
136165
ID string `json:"id,omitempty"`
@@ -143,6 +172,7 @@ type StreamRoute struct {
143172
Sni string `json:"sni,omitempty"`
144173
}
145174

175+
// +k8s:deepcopy-gen=true
146176
type Upstream struct {
147177
Metadata `json:",inline" yaml:",inline"`
148178

@@ -159,13 +189,15 @@ type Upstream struct {
159189
UpstreamHost string `json:"upstream_host,omitempty" yaml:"upstream_host,omitempty"`
160190
}
161191

192+
// +k8s:deepcopy-gen=true
162193
type TLSClass struct {
163194
ClientCERT string `json:"client_cert,omitempty"`
164195
ClientCERTID string `json:"client_cert_id,omitempty"`
165196
ClientKey string `json:"client_key,omitempty"`
166197
Verify *bool `json:"verify,omitempty"`
167198
}
168199

200+
// +k8s:deepcopy-gen=true
169201
type SSL struct {
170202
Metadata `json:",inline" yaml:",inline"`
171203

@@ -176,11 +208,13 @@ type SSL struct {
176208
Type *SSLType `json:"type,omitempty" yaml:"type,omitempty"`
177209
}
178210

211+
// +k8s:deepcopy-gen=true
179212
type Certificate struct {
180213
Certificate string `json:"certificate" yaml:"certificate"`
181214
Key string `json:"key" yaml:"key"`
182215
}
183216

217+
// +k8s:deepcopy-gen=true
184218
type ClientClass struct {
185219
CA string `json:"ca" yaml:"ca"`
186220
Depth *int64 `json:"depth,omitempty" yaml:"depth,omitempty"`
@@ -517,6 +551,7 @@ func (vars *Vars) UnmarshalJSON(p []byte) error {
517551

518552
// StringOrSlice represents a string or a string slice.
519553
// TODO Do not use interface{} to avoid the reflection overheads.
554+
// +k8s:deepcopy-gen=true
520555
type StringOrSlice struct {
521556
StrVal string `json:"-"`
522557
SliceVal []StringOrSlice `json:"-"`

0 commit comments

Comments
 (0)