Skip to content

Commit 8c1166f

Browse files
authored
Merge pull request #440 from weaveworks/smi-v1alpha2-client
SMI TrafficSplit v1alpha2 client
2 parents 0697343 + 68c6d30 commit 8c1166f

31 files changed

+1371
-77
lines changed

hack/update-codegen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh
3030

3131
${CODEGEN_PKG}/generate-groups.sh all \
3232
github.com/weaveworks/flagger/pkg/client github.com/weaveworks/flagger/pkg/apis \
33-
"flagger:v1beta1 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 gloo:v1 projectcontour:v1" \
33+
"flagger:v1beta1 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 smi:v1alpha2 gloo:v1 projectcontour:v1" \
3434
--output-base "${TEMP_DIR}" \
3535
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt
3636

pkg/apis/smi/v1alpha2/doc.go

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// +k8s:deepcopy-gen=package
2+
// +groupName=split.smi-spec.io
3+
4+
package v1alpha2

pkg/apis/smi/v1alpha2/register.go

+48
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/weaveworks/flagger/pkg/apis/smi"
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+
&TrafficSplit{},
44+
&TrafficSplitList{},
45+
)
46+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
47+
return nil
48+
}
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package v1alpha2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +genclient
8+
// +genclient:noStatus
9+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
10+
11+
// TrafficSplit allows users to incrementally direct percentages of traffic
12+
// between various services. It will be used by clients such as ingress
13+
// controllers or service mesh sidecars to split the outgoing traffic to
14+
// different destinations.
15+
type TrafficSplit struct {
16+
metav1.TypeMeta `json:",inline"`
17+
// Standard object's metadata.
18+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
19+
// +optional
20+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
21+
22+
// Specification of the desired behavior of the traffic split.
23+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
24+
// +optional
25+
Spec TrafficSplitSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
26+
27+
// Most recently observed status of the pod.
28+
// This data may not be up to date.
29+
// Populated by the system.
30+
// Read-only.
31+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
32+
// +optional
33+
//Status Status `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
34+
}
35+
36+
// TrafficSplitSpec is the specification for a TrafficSplit
37+
type TrafficSplitSpec struct {
38+
Service string `json:"service,omitempty"`
39+
Backends []TrafficSplitBackend `json:"backends,omitempty"`
40+
}
41+
42+
// TrafficSplitBackend defines a backend
43+
type TrafficSplitBackend struct {
44+
Service string `json:"service,omitempty"`
45+
Weight int `json:"weight,omitempty"`
46+
}
47+
48+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
49+
50+
type TrafficSplitList struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ListMeta `json:"metadata"`
53+
54+
Items []TrafficSplit `json:"items"`
55+
}

pkg/apis/smi/v1alpha2/zz_generated.deepcopy.go

+122
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/clientset.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/fake/clientset_generated.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/fake/register.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/scheme/register.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/typed/smi/v1alpha2/doc.go

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/doc.go

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)