Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 28318bd

Browse files
authored
Merge pull request #80 from servicemeshinterface/root-spec
Add top level spec field to traffic specs and targets
2 parents 7cd7340 + 41764b0 commit 28318bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2911
-130
lines changed

crds/access.yaml

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,82 +3,87 @@ apiVersion: apiextensions.k8s.io/v1beta1
33
kind: CustomResourceDefinition
44
metadata:
55
name: traffictargets.access.smi-spec.io
6-
spec:
6+
spec:
77
group: access.smi-spec.io
88
scope: Namespaced
9-
names:
9+
names:
1010
kind: TrafficTarget
1111
shortNames:
1212
- tt
1313
plural: traffictargets
1414
singular: traffictarget
15-
version: v1alpha1
15+
version: v1alpha2
1616
versions:
17-
- name: v1alpha1
17+
- name: v1alpha2
1818
served: true
1919
storage: true
20+
- name: v1alpha1
21+
served: false
22+
storage: false
2023
validation:
2124
openAPIV3Schema:
22-
required:
23-
- destination
2425
properties:
25-
destination:
26-
description: The destination of this traffic target.
27-
type: object
26+
spec:
2827
required:
29-
- name
30-
- kind
28+
- destination
3129
properties:
32-
kind:
33-
description: Kind of the destination.
34-
type: string
35-
name:
36-
description: Name of the destination.
37-
type: string
38-
namespace:
39-
description: Namespace of the destination.
40-
type: string
41-
port:
42-
description: Port number of the destination.
43-
type: number
44-
specs:
45-
description: Specifications of this traffic target.
46-
type: array
47-
items:
48-
type: object
49-
required:
50-
- name
51-
- kind
52-
properties:
53-
kind:
54-
description: Kind of this spec.
55-
type: string
56-
enum:
57-
- HTTPRouteGroup
58-
- TCPRoute
59-
name:
60-
description: Name of this spec.
61-
type: string
62-
matches:
63-
description: Match conditions of this spec.
64-
type: array
65-
items:
30+
destination:
31+
description: The destination of this traffic target.
32+
type: object
33+
required:
34+
- name
35+
- kind
36+
properties:
37+
kind:
38+
description: Kind of the destination.
39+
type: string
40+
name:
41+
description: Name of the destination.
42+
type: string
43+
namespace:
44+
description: Namespace of the destination.
6645
type: string
67-
sources:
68-
description: Sources of this traffic target.
69-
type: array
70-
items:
71-
type: object
72-
required:
73-
- name
74-
- kind
75-
properties:
76-
kind:
77-
description: Kind of this source.
78-
type: string
79-
name:
80-
description: Name of this source.
81-
type: string
82-
namespace:
83-
description: Namespace of this source.
84-
type: string
46+
port:
47+
description: Port number of the destination.
48+
type: number
49+
rules:
50+
description: Specifications of this traffic target.
51+
type: array
52+
items:
53+
type: object
54+
required:
55+
- name
56+
- kind
57+
properties:
58+
kind:
59+
description: Kind of this spec.
60+
type: string
61+
enum:
62+
- HTTPRouteGroup
63+
- TCPRoute
64+
name:
65+
description: Name of this spec.
66+
type: string
67+
matches:
68+
description: Match conditions of this spec.
69+
type: array
70+
items:
71+
type: string
72+
sources:
73+
description: Sources of this traffic target.
74+
type: array
75+
items:
76+
type: object
77+
required:
78+
- name
79+
- kind
80+
properties:
81+
kind:
82+
description: Kind of this source.
83+
type: string
84+
name:
85+
description: Name of this source.
86+
type: string
87+
namespace:
88+
description: Namespace of this source.
89+
type: string

crds/specs.yaml

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,63 @@ spec:
1212
- htr
1313
plural: httproutegroups
1414
singular: httproutegroup
15-
version: v1alpha2
15+
version: v1alpha3
1616
versions:
17-
- name: v1alpha2
17+
- name: v1alpha3
1818
served: true
1919
storage: true
20+
- name: v1alpha2
21+
served: false
22+
storage: false
2023
- name: v1alpha1
2124
served: false
2225
storage: false
2326
validation:
2427
openAPIV3Schema:
25-
required:
26-
- matches
2728
properties:
28-
matches:
29-
description: Match conditions of this route group.
30-
type: array
31-
items:
32-
type: object
33-
required:
34-
- name
35-
properties:
36-
name:
37-
description: Name of the HTTP route.
38-
type: string
39-
pathRegex:
40-
description: URI path regex of the HTTP route.
41-
type: string
42-
methods:
43-
description: The HTTP methods of this HTTP route.
44-
type: array
45-
items:
46-
type: string
47-
description: The HTTP method of this HTTP route.
48-
enum:
49-
- '*'
50-
- GET
51-
- HEAD
52-
- PUT
53-
- POST
54-
- DELETE
55-
- CONNECT
56-
- OPTIONS
57-
- TRACE
58-
- PATCH
59-
headers:
60-
description: Header match conditions of this route.
61-
type: array
62-
items:
63-
description: Header match condition of this route.
64-
type: object
65-
additionalProperties:
29+
spec:
30+
required:
31+
- matches
32+
properties:
33+
matches:
34+
description: Match conditions of this route group.
35+
type: array
36+
items:
37+
type: object
38+
required:
39+
- name
40+
properties:
41+
name:
42+
description: Name of the HTTP route.
43+
type: string
44+
pathRegex:
45+
description: URI path regex of the HTTP route.
6646
type: string
47+
methods:
48+
description: The HTTP methods of this HTTP route.
49+
type: array
50+
items:
51+
type: string
52+
description: The HTTP method of this HTTP route.
53+
enum:
54+
- '*'
55+
- GET
56+
- HEAD
57+
- PUT
58+
- POST
59+
- DELETE
60+
- CONNECT
61+
- OPTIONS
62+
- TRACE
63+
- PATCH
64+
headers:
65+
description: Header match conditions of this route.
66+
type: array
67+
items:
68+
description: Header match condition of this route.
69+
type: object
70+
additionalProperties:
71+
type: string
6772
---
6873
apiVersion: apiextensions.k8s.io/v1beta1
6974
kind: CustomResourceDefinition
@@ -78,11 +83,14 @@ spec:
7883
- tr
7984
plural: tcproutes
8085
singular: tcproute
81-
version: v1alpha2
86+
version: v1alpha3
8287
versions:
83-
- name: v1alpha2
88+
- name: v1alpha3
8489
served: true
8590
storage: true
91+
- name: v1alpha2
92+
served: false
93+
storage: false
8694
- name: v1alpha1
8795
served: false
8896
storage: false

crds/split.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ spec:
3131
JSONPath: .spec.service
3232
validation:
3333
openAPIV3Schema:
34-
required:
35-
- spec
3634
properties:
3735
spec:
3836
type: object
@@ -43,6 +41,21 @@ spec:
4341
service:
4442
description: The apex service of this split.
4543
type: string
44+
matches:
45+
description: The HTTP route groups that this traffic split should match.
46+
type: array
47+
items:
48+
type: object
49+
required: ['kind', 'name']
50+
properties:
51+
kind:
52+
description: Kind of the matching group.
53+
type: string
54+
enum:
55+
- HTTPRouteGroup
56+
name:
57+
description: Name of the matching group.
58+
type: string
4659
backends:
4760
description: The backend services of this split.
4861
type: array
@@ -56,18 +69,3 @@ spec:
5669
weight:
5770
description: Traffic weight value of this backend.
5871
type: number
59-
matches:
60-
description: The HTTP route groups that this traffic split should match.
61-
type: array
62-
items:
63-
type: object
64-
required: ['kind', 'name']
65-
properties:
66-
kind:
67-
description: Kind of the matching group.
68-
type: string
69-
enum:
70-
- HTTPRouteGroup
71-
name:
72-
description: Name of the matching group.
73-
type: string

hack/update-codegen.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ function generate_client() {
5656
}
5757

5858
echo "##### Generating specs client ######"
59-
generate_client "specs" "v1alpha1,v1alpha2"
59+
generate_client "specs" "v1alpha1,v1alpha2,v1alpha3"
6060

6161
echo ""
6262
echo "###### Generating split client ######"
6363
generate_client "split" "v1alpha1,v1alpha2,v1alpha3"
6464

6565
echo ""
6666
echo "##### Generating access client ######"
67-
generate_client "access" "v1alpha1"
67+
generate_client "access" "v1alpha1,v1alpha2"
6868

6969
echo ""
7070
echo "##### Generating metrics client ######"

pkg/apis/access/v1alpha2/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// +k8s:deepcopy-gen=package
2+
// +groupName=access.smi-spec.io
3+
4+
package v1alpha2

pkg/apis/access/v1alpha2/register.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
8+
ts "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access"
9+
)
10+
11+
// SchemeGroupVersion is the identifier for the API which includes
12+
// the name of the group and the version of the API
13+
var SchemeGroupVersion = schema.GroupVersion{
14+
Group: ts.GroupName,
15+
Version: "v1alpha2",
16+
}
17+
18+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
19+
func Kind(kind string) schema.GroupKind {
20+
return SchemeGroupVersion.WithKind(kind).GroupKind()
21+
}
22+
23+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
24+
func Resource(resource string) schema.GroupResource {
25+
return SchemeGroupVersion.WithResource(resource).GroupResource()
26+
}
27+
28+
var (
29+
// SchemeBuilder collects functions that add things to a scheme. It's to allow
30+
// code to compile without explicitly referencing generated types. You should
31+
// declare one in each package that will have generated deep copy or conversion
32+
// functions.
33+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
34+
35+
// AddToScheme applies all the stored functions to the scheme. A non-nil error
36+
// indicates that one function failed and the attempt was abandoned.
37+
AddToScheme = SchemeBuilder.AddToScheme
38+
)
39+
40+
// Adds the list of known types to Scheme.
41+
func addKnownTypes(scheme *runtime.Scheme) error {
42+
scheme.AddKnownTypes(SchemeGroupVersion,
43+
&TrafficTarget{},
44+
&TrafficTargetList{},
45+
)
46+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
47+
return nil
48+
}

0 commit comments

Comments
 (0)