You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/06 10:00:17 UTC

[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #572: feat: add v2beta1 structure for ApisixRoute

tokers commented on a change in pull request #572:
URL: https://github.com/apache/apisix-ingress-controller/pull/572#discussion_r664414075



##########
File path: pkg/kube/apisix/apis/config/v2beta1/types.go
##########
@@ -0,0 +1,227 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package v2beta1
+
+import (
+	"encoding/json"
+
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// +genclient
+// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+// +kubebuilder:subresource:status
+// ApisixRoute is used to define the route rules and upstreams for Apache APISIX.
+type ApisixRoute struct {
+	metav1.TypeMeta   `json:",inline" yaml:",inline"`
+	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
+	Spec              *ApisixRouteSpec `json:"spec,omitempty" yaml:"spec,omitempty"`

Review comment:
       We may don't need the pointer.

##########
File path: samples/deploy/crd/v1beta1/ApisixRoute.yaml
##########
@@ -44,7 +44,11 @@ spec:
     - name: v1
       served: true
       storage: false
+      deprecated: true
     - name: v2alpha1
+      served: true
+      storage: false

Review comment:
       We may still keep the `v2alpha1` as the storage version, once the v2beta1 logic are completed, we can migrate from v2alpha1 to v2beta1.

##########
File path: samples/deploy/crd/v1beta1/ApisixRoute.yaml
##########
@@ -262,3 +267,43 @@ spec:
                     required:
                       - serviceName
                       - servicePort
+            stream:
+              type: array
+              minItems: 1
+              items:
+                type: object
+                required: [ "name", "match", "backend", "protocol" ]
+                properties:
+                  "protocol":
+                    type: string
+                    enum: [ "TCP", "UDP" ]
+                  name:
+                    type: string
+                    minLength: 1
+                  match:
+                    type: object
+                    properties:
+                      ingressPort:
+                        type: integer
+                        minimum: 1
+                        maximum: 65535
+                    required:
+                      - ingressPort
+                  backend:
+                    type: object
+                    properties:
+                      serviceName:
+                        type: string
+                        minLength: 1
+                      servicePort:
+                        type: integer
+                        minimum: 1
+                        maximum: 65535
+                      resolveGranualrity:
+                        type: string
+                        enum: [ "endpoint", "service" ]
+                      subset:
+                        type: string
+                    required:
+                      - serviceName
+                      - servicePort

Review comment:
       EOL missing.

##########
File path: pkg/kube/apisix/apis/config/v2beta1/types.go
##########
@@ -0,0 +1,227 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package v2beta1
+
+import (
+	"encoding/json"
+
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// +genclient
+// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+// +kubebuilder:subresource:status
+// ApisixRoute is used to define the route rules and upstreams for Apache APISIX.
+type ApisixRoute struct {
+	metav1.TypeMeta   `json:",inline" yaml:",inline"`
+	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
+	Spec              *ApisixRouteSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
+	Status            ApisixStatus     `json:"status,omitempty" yaml:"status,omitempty"`
+}
+
+// ApisixStatus is the status report for Apisix ingress Resources
+type ApisixStatus struct {
+	Conditions *[]metav1.Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"`

Review comment:
       I think a slice is enough, why we need a pointer which points to a slice.

##########
File path: pkg/kube/apisix/apis/config/v2beta1/types.go
##########
@@ -0,0 +1,227 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package v2beta1
+
+import (
+	"encoding/json"
+
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// +genclient
+// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+// +kubebuilder:subresource:status
+// ApisixRoute is used to define the route rules and upstreams for Apache APISIX.
+type ApisixRoute struct {
+	metav1.TypeMeta   `json:",inline" yaml:",inline"`
+	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
+	Spec              *ApisixRouteSpec `json:"spec,omitempty" yaml:"spec,omitempty"`

Review comment:
       We may don't need the pointer.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org