Skip to content

Commit d3efd58

Browse files
committed
feat: implement ApisixRoute controller
1 parent e365525 commit d3efd58

File tree

11 files changed

+730
-59
lines changed

11 files changed

+730
-59
lines changed

api/v2/apisixglobalrule_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@ type ApisixGlobalRuleList struct {
5151
}
5252

5353
func init() {
54+
var a ApisixGlobalRule
55+
a.GetResourceVersion()
56+
a.GetResourceVersion()
5457
SchemeBuilder.Register(&ApisixGlobalRule{}, &ApisixGlobalRuleList{})
5558
}

api/v2/apisixroute_types.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
package v2
1414

1515
import (
16-
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
16+
"encoding/json"
17+
1718
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1819
"k8s.io/apimachinery/pkg/util/intstr"
1920
)
@@ -218,7 +219,21 @@ type ApisixRouteHTTPMatchExpr struct {
218219

219220
// ApisixRoutePluginConfig is the configuration for
220221
// any plugins.
221-
type ApisixRoutePluginConfig map[string]apiextensionsv1.JSON
222+
type ApisixRoutePluginConfig map[string]any
223+
224+
func (p ApisixRoutePluginConfig) DeepCopyInto(out *ApisixRoutePluginConfig) {
225+
b, _ := json.Marshal(&p)
226+
_ = json.Unmarshal(b, out)
227+
}
228+
229+
func (p *ApisixRoutePluginConfig) DeepCopy() *ApisixRoutePluginConfig {
230+
if p == nil {
231+
return nil
232+
}
233+
out := new(ApisixRoutePluginConfig)
234+
p.DeepCopyInto(out)
235+
return out
236+
}
222237

223238
// ApisixRouteAuthenticationKeyAuth is the keyAuth-related
224239
// configuration in ApisixRouteAuthentication.

api/v2/shared_types.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package v2
2+
3+
import (
4+
"time"
5+
6+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
7+
)
8+
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// http://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
21+
type (
22+
// ApisixRouteConditionType is a type of condition for a route.
23+
ApisixRouteConditionType = gatewayv1.RouteConditionType
24+
// ApisixRouteConditionReason is a reason for a route condition.
25+
ApisixRouteConditionReason = gatewayv1.RouteConditionReason
26+
)
27+
28+
const (
29+
ApisixRouteConditionTypeAccepted ApisixRouteConditionType = gatewayv1.RouteConditionAccepted
30+
ApisixRouteConditionReasonAccepted ApisixRouteConditionReason = gatewayv1.RouteReasonAccepted
31+
ApisixRouteConditionReasonInvalidHTTP ApisixRouteConditionReason = "InvalidHTTP"
32+
)
33+
34+
const (
35+
// DefaultUpstreamTimeout represents the default connect,
36+
// read and send timeout (in seconds) with upstreams.
37+
DefaultUpstreamTimeout = 60 * time.Second
38+
)
39+
40+
const (
41+
// OpEqual means the equal ("==") operator in nginxVars.
42+
OpEqual = "Equal"
43+
// OpNotEqual means the not equal ("~=") operator in nginxVars.
44+
OpNotEqual = "NotEqual"
45+
// OpGreaterThan means the greater than (">") operator in nginxVars.
46+
OpGreaterThan = "GreaterThan"
47+
// OpGreaterThanEqual means the greater than (">=") operator in nginxVars.
48+
OpGreaterThanEqual = "GreaterThanEqual"
49+
// OpLessThan means the less than ("<") operator in nginxVars.
50+
OpLessThan = "LessThan"
51+
// OpLessThanEqual means the less than equal ("<=") operator in nginxVars.
52+
OpLessThanEqual = "LessThanEqual"
53+
// OpRegexMatch means the regex match ("~~") operator in nginxVars.
54+
OpRegexMatch = "RegexMatch"
55+
// OpRegexNotMatch means the regex not match ("!~~") operator in nginxVars.
56+
OpRegexNotMatch = "RegexNotMatch"
57+
// OpRegexMatchCaseInsensitive means the regex match "~*" (case insensitive mode) operator in nginxVars.
58+
OpRegexMatchCaseInsensitive = "RegexMatchCaseInsensitive"
59+
// OpRegexNotMatchCaseInsensitive means the regex not match "!~*" (case insensitive mode) operator in nginxVars.
60+
OpRegexNotMatchCaseInsensitive = "RegexNotMatchCaseInsensitive"
61+
// OpIn means the in operator ("in") in nginxVars.
62+
OpIn = "In"
63+
// OpNotIn means the not in operator ("not_in") in nginxVars.
64+
OpNotIn = "NotIn"
65+
66+
// ScopeQuery means the route match expression subject is in the querystring.
67+
ScopeQuery = "Query"
68+
// ScopeHeader means the route match expression subject is in request headers.
69+
ScopeHeader = "Header"
70+
// ScopePath means the route match expression subject is the uri path.
71+
ScopePath = "Path"
72+
// ScopeCookie means the route match expression subject is in cookie.
73+
ScopeCookie = "Cookie"
74+
// ScopeVariable means the route match expression subject is in variable.
75+
ScopeVariable = "Variable"
76+
)

api/v2/zz_generated.deepcopy.go

Lines changed: 1 addition & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)