Skip to content

Commit e0f6766

Browse files
committed
Merge remote-tracking branch 'origin/release-v2-dev' into chore/condition-assertion
# Conflicts: # internal/controller/httproutepolicy.go
2 parents 5c858bb + 4ee0e26 commit e0f6766

35 files changed

+1050
-442
lines changed

api/v1alpha1/backendtrafficpolicy_types.go

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type BackendTrafficPolicy struct {
2222
metav1.TypeMeta `json:",inline"`
2323
metav1.ObjectMeta `json:"metadata,omitempty"`
2424

25+
// BackendTrafficPolicySpec defines traffic handling policies applied to backend services,
26+
// such as load balancing strategy, connection settings, and failover behavior.
2527
Spec BackendTrafficPolicySpec `json:"spec,omitempty"`
2628
Status PolicyStatus `json:"status,omitempty"`
2729
}
@@ -37,57 +39,71 @@ type BackendTrafficPolicySpec struct {
3739
// LoadBalancer represents the load balancer configuration for Kubernetes Service.
3840
// The default strategy is round robin.
3941
LoadBalancer *LoadBalancer `json:"loadbalancer,omitempty" yaml:"loadbalancer,omitempty"`
40-
// The scheme used to talk with the upstream.
41-
//
42+
// Scheme is the protocol used to communicate with the upstream.
43+
// Default is `http`.
44+
// Can be one of `http`, `https`, `grpc`, or `grpcs`.
4245
// +kubebuilder:validation:Enum=http;https;grpc;grpcs;
4346
// +kubebuilder:default=http
4447
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
4548

46-
// How many times that the proxy (Apache APISIX) should do when
47-
// errors occur (error, timeout or bad http status codes like 500, 502).
49+
// Retries specify the number of times the gateway should retry sending
50+
// requests when errors such as timeouts or 502 errors occur.
4851
// +optional
4952
Retries *int `json:"retries,omitempty" yaml:"retries,omitempty"`
5053

51-
// Timeout settings for the read, send and connect to the upstream.
54+
// Timeout sets the read, send, and connect timeouts to the upstream.
5255
Timeout *Timeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
5356

54-
// Configures the host when the request is forwarded to the upstream.
55-
// Can be one of pass, node or rewrite.
57+
// PassHost configures how the host header should be determined when a
58+
// request is forwarded to the upstream.
59+
// Default is `pass`.
60+
// Can be one of `pass`, `node` or `rewrite`.
5661
//
5762
// +kubebuilder:validation:Enum=pass;node;rewrite;
5863
// +kubebuilder:default=pass
5964
PassHost string `json:"passHost,omitempty" yaml:"passHost,omitempty"`
6065

61-
// Specifies the host of the Upstream request. This is only valid if
62-
// the passHost is set to rewrite
66+
// UpstreamHost specifies the host of the Upstream request. Used only if
67+
// passHost is set to `rewrite`.
6368
Host Hostname `json:"upstreamHost,omitempty" yaml:"upstreamHost,omitempty"`
6469
}
6570

6671
// LoadBalancer describes the load balancing parameters.
6772
// +kubebuilder:validation:XValidation:rule="!(has(self.key) && self.type != 'chash')"
6873
type LoadBalancer struct {
74+
// Type specifies the load balancing algorithms.
75+
// Default is `roundrobin`.
76+
// Can be one of `roundrobin`, `chash`, `ewma`, or `least_conn`.
6977
// +kubebuilder:validation:Enum=roundrobin;chash;ewma;least_conn;
7078
// +kubebuilder:default=roundrobin
7179
// +kubebuilder:validation:Required
7280
Type string `json:"type" yaml:"type"`
73-
// The HashOn and Key fields are required when Type is "chash".
74-
// HashOn represents the key fetching scope.
81+
// HashOn specified the type of field used for hashing, required when Type is `chash`.
82+
// Default is `vars`.
83+
// Can be one of `vars`, `header`, `cookie`, `consumer`, or `vars_combinations`.
7584
// +kubebuilder:validation:Enum=vars;header;cookie;consumer;vars_combinations;
7685
// +kubebuilder:default=vars
7786
HashOn string `json:"hashOn,omitempty" yaml:"hashOn,omitempty"`
78-
// Key represents the hash key.
87+
// Key is used with HashOn, generally required when Type is `chash`.
88+
// When HashOn is `header` or `cookie`, specifies the name of the header or cookie.
89+
// When HashOn is `consumer`, key is not required, as the consumer name is used automatically.
90+
// When HashOn is `vars` or `vars_combinations`, key refers to one or a combination of
91+
// [built-in variables](/enterprise/reference/built-in-variables).
7992
Key string `json:"key,omitempty" yaml:"key,omitempty"`
8093
}
8194

8295
type Timeout struct {
96+
// Connection timeout. Default is `60s`.
8397
// +kubebuilder:default="60s"
8498
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
8599
// +kubebuilder:validation:Type=string
86100
Connect metav1.Duration `json:"connect,omitempty" yaml:"connect,omitempty"`
101+
// Send timeout. Default is `60s`.
87102
// +kubebuilder:default="60s"
88103
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
89104
// +kubebuilder:validation:Type=string
90105
Send metav1.Duration `json:"send,omitempty" yaml:"send,omitempty"`
106+
// Read timeout. Default is `60s`.
91107
// +kubebuilder:default="60s"
92108
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
93109
// +kubebuilder:validation:Type=string

api/v1alpha1/consumer_types.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,54 @@ type Consumer struct {
2323
metav1.TypeMeta `json:",inline"`
2424
metav1.ObjectMeta `json:"metadata,omitempty"`
2525

26+
// ConsumerSpec defines the configuration for a consumer, including consumer name,
27+
// authentication credentials, and plugin settings.
2628
Spec ConsumerSpec `json:"spec,omitempty"`
2729
Status Status `json:"status,omitempty"`
2830
}
2931

3032
type ConsumerSpec struct {
31-
GatewayRef GatewayRef `json:"gatewayRef,omitempty"`
33+
// GatewayRef specifies the gateway details.
34+
GatewayRef GatewayRef `json:"gatewayRef,omitempty"`
35+
// Credentials specifies the credential details of a consumer.
3236
Credentials []Credential `json:"credentials,omitempty"`
33-
Plugins []Plugin `json:"plugins,omitempty"`
37+
// Plugins define the plugins associated with a consumer.
38+
Plugins []Plugin `json:"plugins,omitempty"`
3439
}
3540

3641
type GatewayRef struct {
42+
// Name is the name of the gateway.
3743
// +kubebuilder:validation:Required
3844
// +kubebuilder:validation:MinLength=1
3945
Name string `json:"name"`
46+
// Kind is the type of Kubernetes object. Default is `Gateway`.
4047
// +kubebuilder:default=Gateway
4148
Kind *string `json:"kind,omitempty"`
49+
// Group is the API group the resource belongs to. Default is `gateway.networking.k8s.io`.
4250
// +kubebuilder:default=gateway.networking.k8s.io
43-
Group *string `json:"group,omitempty"`
51+
Group *string `json:"group,omitempty"`
52+
// Namespace is namespace of the resource.
4453
Namespace *string `json:"namespace,omitempty"`
4554
}
4655

4756
type Credential struct {
4857
// +kubebuilder:validation:Required
4958
// +kubebuilder:validation:Enum=jwt-auth;basic-auth;key-auth;hmac-auth;
50-
Type string `json:"type"`
51-
Config apiextensionsv1.JSON `json:"config,omitempty"`
52-
SecretRef *SecretReference `json:"secretRef,omitempty"`
53-
Name string `json:"name,omitempty"`
59+
// Type specifies the type of authentication to configure credentials for.
60+
// Can be one of `jwt-auth`, `basic-auth`, `key-auth`, or `hmac-auth`.
61+
Type string `json:"type"`
62+
// Config specifies the credential details for authentication.
63+
Config apiextensionsv1.JSON `json:"config,omitempty"`
64+
// SecretRef references to the Secret that contains the credentials.
65+
SecretRef *SecretReference `json:"secretRef,omitempty"`
66+
// Name is the name of the credential.
67+
Name string `json:"name,omitempty"`
5468
}
5569

5670
type SecretReference struct {
57-
Name string `json:"name"`
71+
// Name is the name of the secret.
72+
Name string `json:"name"`
73+
// Namespace is the namespace of the secret.
5874
Namespace *string `json:"namespace,omitempty"`
5975
}
6076

api/v1alpha1/gatewayproxy_types.go

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,125 +20,139 @@ import (
2020
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2121
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2222

23-
// GatewayProxySpec defines the desired state of GatewayProxy
23+
// GatewayProxySpec defines the desired state of GatewayProxy.
2424
type GatewayProxySpec struct {
2525
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2626
// Important: Run "make" to regenerate code after modifying this file
2727

28-
PublishService string `json:"publishService,omitempty"`
29-
StatusAddress []string `json:"statusAddress,omitempty"`
30-
Provider *GatewayProxyProvider `json:"provider,omitempty"`
31-
Plugins []GatewayProxyPlugin `json:"plugins,omitempty"`
28+
// PublishService specifies the LoadBalancer-type Service whose external address the controller uses to
29+
// update the status of Ingress resources.
30+
PublishService string `json:"publishService,omitempty"`
31+
// StatusAddress specifies the external IP addresses that the controller uses to populate the status field
32+
// of GatewayProxy or Ingress resources for developers to access.
33+
StatusAddress []string `json:"statusAddress,omitempty"`
34+
// Provider configures the provider details.
35+
Provider *GatewayProxyProvider `json:"provider,omitempty"`
36+
// Plugins configure global plugins.
37+
Plugins []GatewayProxyPlugin `json:"plugins,omitempty"`
38+
// PluginMetadata configures common configurations shared by all plugin instances of the same name.
3239
PluginMetadata map[string]apiextensionsv1.JSON `json:"pluginMetadata,omitempty"`
3340
}
3441

35-
// ProviderType defines the type of provider
42+
// ProviderType defines the type of provider.
3643
// +kubebuilder:validation:Enum=ControlPlane
3744
type ProviderType string
3845

3946
const (
40-
// ProviderTypeControlPlane represents the control plane provider type
47+
// ProviderTypeControlPlane represents the control plane provider type.
4148
ProviderTypeControlPlane ProviderType = "ControlPlane"
4249
)
4350

44-
// GatewayProxyProvider defines the provider configuration for GatewayProxy
51+
// GatewayProxyProvider defines the provider configuration for GatewayProxy.
4552
// +kubebuilder:validation:XValidation:rule="self.type == 'ControlPlane' ? has(self.controlPlane) : true",message="controlPlane must be specified when type is ControlPlane"
4653
type GatewayProxyProvider struct {
47-
// Type specifies the type of provider
54+
// Type specifies the type of provider. Can only be `ControlPlane`.
4855
// +kubebuilder:validation:Required
4956
Type ProviderType `json:"type"`
5057

51-
// ControlPlane specifies the configuration for control plane provider
58+
// ControlPlane specifies the configuration for control plane provider.
5259
// +optional
5360
ControlPlane *ControlPlaneProvider `json:"controlPlane,omitempty"`
5461
}
5562

56-
// AuthType defines the type of authentication
63+
// AuthType defines the type of authentication.
5764
// +kubebuilder:validation:Enum=AdminKey
5865
type AuthType string
5966

6067
const (
61-
// AuthTypeAdminKey represents the admin key authentication type
68+
// AuthTypeAdminKey represents the admin key authentication type.
6269
AuthTypeAdminKey AuthType = "AdminKey"
6370
)
6471

65-
// SecretKeySelector defines a reference to a specific key within a Secret
72+
// SecretKeySelector defines a reference to a specific key within a Secret.
6673
type SecretKeySelector struct {
67-
// Name is the name of the secret
74+
// Name is the name of the secret.
6875
// +kubebuilder:validation:Required
6976
Name string `json:"name"`
7077

71-
// Key is the key in the secret
78+
// Key is the key in the secret to retrieve the secret from.
7279
// +kubebuilder:validation:Required
7380
Key string `json:"key"`
7481
}
7582

76-
// AdminKeyAuth defines the admin key authentication configuration
83+
// AdminKeyAuth defines the admin key authentication configuration.
7784
type AdminKeyAuth struct {
78-
// Value specifies the admin key value directly (not recommended for production)
85+
// Value sets the admin key value explicitly (not recommended for production).
7986
// +optional
8087
Value string `json:"value,omitempty"`
8188

82-
// ValueFrom specifies the source of the admin key
89+
// ValueFrom specifies the source of the admin key.
8390
// +optional
8491
ValueFrom *AdminKeyValueFrom `json:"valueFrom,omitempty"`
8592
}
8693

87-
// AdminKeyValueFrom defines the source of the admin key
94+
// AdminKeyValueFrom defines the source of the admin key.
8895
type AdminKeyValueFrom struct {
89-
// SecretKeyRef references a key in a Secret
96+
// SecretKeyRef references a key in a Secret.
9097
// +optional
9198
SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
9299
}
93100

94-
// ControlPlaneAuth defines the authentication configuration for control plane
101+
// ControlPlaneAuth defines the authentication configuration for control plane.
95102
type ControlPlaneAuth struct {
96-
// Type specifies the type of authentication
103+
// Type specifies the type of authentication.
104+
// Can only be `AdminKey`.
97105
// +kubebuilder:validation:Required
98106
Type AuthType `json:"type"`
99107

100-
// AdminKey specifies the admin key authentication configuration
108+
// AdminKey specifies the admin key authentication configuration.
101109
// +optional
102110
AdminKey *AdminKeyAuth `json:"adminKey,omitempty"`
103111
}
104112

105-
// ControlPlaneProvider defines the configuration for control plane provider
113+
// ControlPlaneProvider defines the configuration for control plane provider.
106114
type ControlPlaneProvider struct {
107-
// Endpoints specifies the list of control plane endpoints
115+
// Endpoints specifies the list of control plane endpoints.
108116
// +kubebuilder:validation:Required
109117
// +kubebuilder:validation:MinItems=1
110118
Endpoints []string `json:"endpoints"`
111119

112-
// TlsVerify specifies whether to verify the TLS certificate of the control plane
120+
// TlsVerify specifies whether to verify the TLS certificate of the control plane.
113121
// +optional
114122
TlsVerify *bool `json:"tlsVerify,omitempty"`
115123

116-
// Auth specifies the authentication configuration
124+
// Auth specifies the authentication configurations.
117125
// +kubebuilder:validation:Required
118126
Auth ControlPlaneAuth `json:"auth"`
119127
}
120128

121129
// +kubebuilder:object:root=true
122-
// GatewayProxy is the Schema for the gatewayproxies API
130+
// GatewayProxy is the Schema for the gatewayproxies API.
123131
type GatewayProxy struct {
124132
metav1.TypeMeta `json:",inline"`
125133
metav1.ObjectMeta `json:"metadata,omitempty"`
126134

135+
// GatewayProxySpec defines the desired state and configuration of a GatewayProxy,
136+
// including networking settings, global plugins, and plugin metadata.
127137
Spec GatewayProxySpec `json:"spec,omitempty"`
128138
}
129139

130140
// +kubebuilder:object:root=true
131-
// GatewayProxyList contains a list of GatewayProxy
141+
// GatewayProxyList contains a list of GatewayProxy.
132142
type GatewayProxyList struct {
133143
metav1.TypeMeta `json:",inline"`
134144
metav1.ListMeta `json:"metadata,omitempty"`
135145
Items []GatewayProxy `json:"items"`
136146
}
137147

148+
// GatewayProxyPlugin contains plugin configurations.
138149
type GatewayProxyPlugin struct {
139-
Name string `json:"name,omitempty"`
140-
Enabled bool `json:"enabled,omitempty"`
141-
Config apiextensionsv1.JSON `json:"config,omitempty"`
150+
// Name is the name of the plugin.
151+
Name string `json:"name,omitempty"`
152+
// Enabled defines whether the plugin is enabled.
153+
Enabled bool `json:"enabled,omitempty"`
154+
// Config defines the plugin's configuration details.
155+
Config apiextensionsv1.JSON `json:"config,omitempty"`
142156
}
143157

144158
func init() {

api/v1alpha1/httproutepolicy_types.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ import (
2020

2121
// HTTPRoutePolicySpec defines the desired state of HTTPRoutePolicy.
2222
type HTTPRoutePolicySpec struct {
23-
// TargetRef identifies an API object (enum: HTTPRoute, Ingress) to apply HTTPRoutePolicy to.
24-
//
25-
// target references.
23+
// TargetRef identifies an API object (i.e. HTTPRoute, Ingress) to apply HTTPRoutePolicy to.
2624
// +kubebuilder:validation:MinItems=1
2725
// +kubebuilder:validation:MaxItems=16
2826
TargetRefs []gatewayv1alpha2.LocalPolicyTargetReferenceWithSectionName `json:"targetRefs"`
29-
30-
Priority *int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
31-
Vars []apiextensionsv1.JSON `json:"vars,omitempty" yaml:"vars,omitempty"`
27+
// Priority sets the priority for route. A higher value sets a higher priority in route matching.
28+
Priority *int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
29+
// Vars sets the request matching conditions.
30+
Vars []apiextensionsv1.JSON `json:"vars,omitempty" yaml:"vars,omitempty"`
3231
}
3332

3433
// +kubebuilder:object:root=true
@@ -39,6 +38,8 @@ type HTTPRoutePolicy struct {
3938
metav1.TypeMeta `json:",inline"`
4039
metav1.ObjectMeta `json:"metadata,omitempty"`
4140

41+
// HTTPRoutePolicySpec defines the desired state and configuration of a HTTPRoutePolicy,
42+
// including route priority and request matching conditions.
4243
Spec HTTPRoutePolicySpec `json:"spec,omitempty"`
4344
Status PolicyStatus `json:"status,omitempty"`
4445
}

api/v1alpha1/pluginconfig_types.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,35 @@ import (
2222

2323
// +kubebuilder:object:root=true
2424

25-
// PluginConfig is the Schema for the PluginConfigs API
25+
// PluginConfig is the Schema for the PluginConfigs API.
2626
type PluginConfig struct {
2727
metav1.TypeMeta `json:",inline"`
2828
metav1.ObjectMeta `json:"metadata,omitempty"`
2929

30+
// PluginConfigSpec defines the desired state of a PluginConfig,
31+
// in which plugins and their configurations are specified.
3032
Spec PluginConfigSpec `json:"spec,omitempty"`
3133
}
3234

33-
// PluginConfigSpec defines the desired state of PluginConfig
35+
// PluginConfigSpec defines the desired state of PluginConfig.
3436
type PluginConfigSpec struct {
37+
// Plugins are an array of plugins and their configurations to be applied.
3538
Plugins []Plugin `json:"plugins"`
3639
}
3740

3841
// +kubebuilder:object:root=true
3942

40-
// PluginConfigList contains a list of PluginConfig
43+
// PluginConfigList contains a list of PluginConfig.
4144
type PluginConfigList struct {
4245
metav1.TypeMeta `json:",inline"`
4346
metav1.ListMeta `json:"metadata,omitempty"`
4447
Items []PluginConfig `json:"items"`
4548
}
4649

4750
type Plugin struct {
48-
// The plugin name.
51+
// Name is the name of the plugin.
4952
Name string `json:"name" yaml:"name"`
50-
// Plugin configuration.
53+
// Config is plugin configuration details.
5154
Config apiextensionsv1.JSON `json:"config,omitempty" yaml:"config,omitempty"`
5255
}
5356

0 commit comments

Comments
 (0)