Compare commits

...

2 Commits

Author SHA1 Message Date
liheng.zms 1152487c76 rollout api v0.4.2 2024-06-11 16:30:57 +08:00
守辰 7cd83236d7 add missing scheme
Signed-off-by: 守辰 <shouchen.zz@alibaba-inc.com>
2024-01-22 20:15:07 +08:00
40 changed files with 1007 additions and 121 deletions

View File

@ -12,7 +12,6 @@ vet:
# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@hack/generate_client.sh
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -40,6 +40,10 @@ func (c *FakeRolloutsV1alpha1) RolloutHistories(namespace string) v1alpha1.Rollo
return &FakeRolloutHistories{c, namespace}
}
func (c *FakeRolloutsV1alpha1) TrafficRoutings(namespace string) v1alpha1.TrafficRoutingInterface {
return &FakeTrafficRoutings{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeRolloutsV1alpha1) RESTClient() rest.Interface {

View File

@ -0,0 +1,142 @@
/*
Copyright 2024 The Kruise Authors.
Licensed 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/openkruise/kruise-rollout-api/rollouts/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeTrafficRoutings implements TrafficRoutingInterface
type FakeTrafficRoutings struct {
Fake *FakeRolloutsV1alpha1
ns string
}
var trafficroutingsResource = schema.GroupVersionResource{Group: "rollouts.kruise.io", Version: "v1alpha1", Resource: "trafficroutings"}
var trafficroutingsKind = schema.GroupVersionKind{Group: "rollouts.kruise.io", Version: "v1alpha1", Kind: "TrafficRouting"}
// Get takes name of the trafficRouting, and returns the corresponding trafficRouting object, and an error if there is any.
func (c *FakeTrafficRoutings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficRouting, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(trafficroutingsResource, c.ns, name), &v1alpha1.TrafficRouting{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.TrafficRouting), err
}
// List takes label and field selectors, and returns the list of TrafficRoutings that match those selectors.
func (c *FakeTrafficRoutings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficRoutingList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(trafficroutingsResource, trafficroutingsKind, c.ns, opts), &v1alpha1.TrafficRoutingList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.TrafficRoutingList{ListMeta: obj.(*v1alpha1.TrafficRoutingList).ListMeta}
for _, item := range obj.(*v1alpha1.TrafficRoutingList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested trafficRoutings.
func (c *FakeTrafficRoutings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(trafficroutingsResource, c.ns, opts))
}
// Create takes the representation of a trafficRouting and creates it. Returns the server's representation of the trafficRouting, and an error, if there is any.
func (c *FakeTrafficRoutings) Create(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.CreateOptions) (result *v1alpha1.TrafficRouting, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(trafficroutingsResource, c.ns, trafficRouting), &v1alpha1.TrafficRouting{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.TrafficRouting), err
}
// Update takes the representation of a trafficRouting and updates it. Returns the server's representation of the trafficRouting, and an error, if there is any.
func (c *FakeTrafficRoutings) Update(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (result *v1alpha1.TrafficRouting, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(trafficroutingsResource, c.ns, trafficRouting), &v1alpha1.TrafficRouting{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.TrafficRouting), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeTrafficRoutings) UpdateStatus(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (*v1alpha1.TrafficRouting, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(trafficroutingsResource, "status", c.ns, trafficRouting), &v1alpha1.TrafficRouting{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.TrafficRouting), err
}
// Delete takes name of the trafficRouting and deletes it. Returns an error if one occurs.
func (c *FakeTrafficRoutings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(trafficroutingsResource, c.ns, name), &v1alpha1.TrafficRouting{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeTrafficRoutings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(trafficroutingsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.TrafficRoutingList{})
return err
}
// Patch applies the patch and returns the patched trafficRouting.
func (c *FakeTrafficRoutings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficRouting, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(trafficroutingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.TrafficRouting{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.TrafficRouting), err
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -23,3 +23,5 @@ type BatchReleaseExpansion interface{}
type RolloutExpansion interface{}
type RolloutHistoryExpansion interface{}
type TrafficRoutingExpansion interface{}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ type RolloutsV1alpha1Interface interface {
BatchReleasesGetter
RolloutsGetter
RolloutHistoriesGetter
TrafficRoutingsGetter
}
// RolloutsV1alpha1Client is used to interact with features provided by the rollouts.kruise.io group.
@ -48,6 +49,10 @@ func (c *RolloutsV1alpha1Client) RolloutHistories(namespace string) RolloutHisto
return newRolloutHistories(c, namespace)
}
func (c *RolloutsV1alpha1Client) TrafficRoutings(namespace string) TrafficRoutingInterface {
return newTrafficRoutings(c, namespace)
}
// NewForConfig creates a new RolloutsV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*RolloutsV1alpha1Client, error) {
config := *c

View File

@ -0,0 +1,195 @@
/*
Copyright 2024 The Kruise Authors.
Licensed 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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
scheme "github.com/openkruise/kruise-rollout-api/client/clientset/versioned/scheme"
v1alpha1 "github.com/openkruise/kruise-rollout-api/rollouts/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// TrafficRoutingsGetter has a method to return a TrafficRoutingInterface.
// A group's client should implement this interface.
type TrafficRoutingsGetter interface {
TrafficRoutings(namespace string) TrafficRoutingInterface
}
// TrafficRoutingInterface has methods to work with TrafficRouting resources.
type TrafficRoutingInterface interface {
Create(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.CreateOptions) (*v1alpha1.TrafficRouting, error)
Update(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (*v1alpha1.TrafficRouting, error)
UpdateStatus(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (*v1alpha1.TrafficRouting, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.TrafficRouting, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.TrafficRoutingList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficRouting, err error)
TrafficRoutingExpansion
}
// trafficRoutings implements TrafficRoutingInterface
type trafficRoutings struct {
client rest.Interface
ns string
}
// newTrafficRoutings returns a TrafficRoutings
func newTrafficRoutings(c *RolloutsV1alpha1Client, namespace string) *trafficRoutings {
return &trafficRoutings{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the trafficRouting, and returns the corresponding trafficRouting object, and an error if there is any.
func (c *trafficRoutings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficRouting, err error) {
result = &v1alpha1.TrafficRouting{}
err = c.client.Get().
Namespace(c.ns).
Resource("trafficroutings").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of TrafficRoutings that match those selectors.
func (c *trafficRoutings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficRoutingList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.TrafficRoutingList{}
err = c.client.Get().
Namespace(c.ns).
Resource("trafficroutings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested trafficRoutings.
func (c *trafficRoutings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("trafficroutings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a trafficRouting and creates it. Returns the server's representation of the trafficRouting, and an error, if there is any.
func (c *trafficRoutings) Create(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.CreateOptions) (result *v1alpha1.TrafficRouting, err error) {
result = &v1alpha1.TrafficRouting{}
err = c.client.Post().
Namespace(c.ns).
Resource("trafficroutings").
VersionedParams(&opts, scheme.ParameterCodec).
Body(trafficRouting).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a trafficRouting and updates it. Returns the server's representation of the trafficRouting, and an error, if there is any.
func (c *trafficRoutings) Update(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (result *v1alpha1.TrafficRouting, err error) {
result = &v1alpha1.TrafficRouting{}
err = c.client.Put().
Namespace(c.ns).
Resource("trafficroutings").
Name(trafficRouting.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(trafficRouting).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *trafficRoutings) UpdateStatus(ctx context.Context, trafficRouting *v1alpha1.TrafficRouting, opts v1.UpdateOptions) (result *v1alpha1.TrafficRouting, err error) {
result = &v1alpha1.TrafficRouting{}
err = c.client.Put().
Namespace(c.ns).
Resource("trafficroutings").
Name(trafficRouting.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(trafficRouting).
Do(ctx).
Into(result)
return
}
// Delete takes name of the trafficRouting and deletes it. Returns an error if one occurs.
func (c *trafficRoutings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("trafficroutings").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *trafficRoutings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("trafficroutings").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched trafficRouting.
func (c *trafficRoutings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficRouting, err error) {
result = &v1alpha1.TrafficRouting{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("trafficroutings").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -59,6 +59,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
return &genericInformer{resource: resource.GroupResource(), informer: f.Rollouts().V1alpha1().Rollouts().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("rollouthistories"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rollouts().V1alpha1().RolloutHistories().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("trafficroutings"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rollouts().V1alpha1().TrafficRoutings().Informer()}, nil
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -30,6 +30,8 @@ type Interface interface {
Rollouts() RolloutInformer
// RolloutHistories returns a RolloutHistoryInformer.
RolloutHistories() RolloutHistoryInformer
// TrafficRoutings returns a TrafficRoutingInformer.
TrafficRoutings() TrafficRoutingInformer
}
type version struct {
@ -57,3 +59,8 @@ func (v *version) Rollouts() RolloutInformer {
func (v *version) RolloutHistories() RolloutHistoryInformer {
return &rolloutHistoryInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// TrafficRoutings returns a TrafficRoutingInformer.
func (v *version) TrafficRoutings() TrafficRoutingInformer {
return &trafficRoutingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -0,0 +1,90 @@
/*
Copyright 2024 The Kruise Authors.
Licensed 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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
versioned "github.com/openkruise/kruise-rollout-api/client/clientset/versioned"
internalinterfaces "github.com/openkruise/kruise-rollout-api/client/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/openkruise/kruise-rollout-api/client/listers/rollouts/v1alpha1"
rolloutsv1alpha1 "github.com/openkruise/kruise-rollout-api/rollouts/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// TrafficRoutingInformer provides access to a shared informer and lister for
// TrafficRoutings.
type TrafficRoutingInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.TrafficRoutingLister
}
type trafficRoutingInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewTrafficRoutingInformer constructs a new informer for TrafficRouting type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTrafficRoutingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredTrafficRoutingInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredTrafficRoutingInformer constructs a new informer for TrafficRouting type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredTrafficRoutingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RolloutsV1alpha1().TrafficRoutings(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RolloutsV1alpha1().TrafficRoutings(namespace).Watch(context.TODO(), options)
},
},
&rolloutsv1alpha1.TrafficRouting{},
resyncPeriod,
indexers,
)
}
func (f *trafficRoutingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredTrafficRoutingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *trafficRoutingInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&rolloutsv1alpha1.TrafficRouting{}, f.defaultInformer)
}
func (f *trafficRoutingInformer) Lister() v1alpha1.TrafficRoutingLister {
return v1alpha1.NewTrafficRoutingLister(f.Informer().GetIndexer())
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -41,3 +41,11 @@ type RolloutHistoryListerExpansion interface{}
// RolloutHistoryNamespaceListerExpansion allows custom methods to be added to
// RolloutHistoryNamespaceLister.
type RolloutHistoryNamespaceListerExpansion interface{}
// TrafficRoutingListerExpansion allows custom methods to be added to
// TrafficRoutingLister.
type TrafficRoutingListerExpansion interface{}
// TrafficRoutingNamespaceListerExpansion allows custom methods to be added to
// TrafficRoutingNamespaceLister.
type TrafficRoutingNamespaceListerExpansion interface{}

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2022 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -0,0 +1,99 @@
/*
Copyright 2024 The Kruise Authors.
Licensed 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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/openkruise/kruise-rollout-api/rollouts/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// TrafficRoutingLister helps list TrafficRoutings.
// All objects returned here must be treated as read-only.
type TrafficRoutingLister interface {
// List lists all TrafficRoutings in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.TrafficRouting, err error)
// TrafficRoutings returns an object that can list and get TrafficRoutings.
TrafficRoutings(namespace string) TrafficRoutingNamespaceLister
TrafficRoutingListerExpansion
}
// trafficRoutingLister implements the TrafficRoutingLister interface.
type trafficRoutingLister struct {
indexer cache.Indexer
}
// NewTrafficRoutingLister returns a new TrafficRoutingLister.
func NewTrafficRoutingLister(indexer cache.Indexer) TrafficRoutingLister {
return &trafficRoutingLister{indexer: indexer}
}
// List lists all TrafficRoutings in the indexer.
func (s *trafficRoutingLister) List(selector labels.Selector) (ret []*v1alpha1.TrafficRouting, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.TrafficRouting))
})
return ret, err
}
// TrafficRoutings returns an object that can list and get TrafficRoutings.
func (s *trafficRoutingLister) TrafficRoutings(namespace string) TrafficRoutingNamespaceLister {
return trafficRoutingNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// TrafficRoutingNamespaceLister helps list and get TrafficRoutings.
// All objects returned here must be treated as read-only.
type TrafficRoutingNamespaceLister interface {
// List lists all TrafficRoutings in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.TrafficRouting, err error)
// Get retrieves the TrafficRouting from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.TrafficRouting, error)
TrafficRoutingNamespaceListerExpansion
}
// trafficRoutingNamespaceLister implements the TrafficRoutingNamespaceLister
// interface.
type trafficRoutingNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all TrafficRoutings in the indexer for a given namespace.
func (s trafficRoutingNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.TrafficRouting, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.TrafficRouting))
})
return ret, err
}
// Get retrieves the TrafficRouting from the indexer for a given namespace and name.
func (s trafficRoutingNamespaceLister) Get(name string) (*v1alpha1.TrafficRouting, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("trafficrouting"), name)
}
return obj.(*v1alpha1.TrafficRouting), nil
}

View File

@ -50,6 +50,10 @@ type ReleasePlan struct {
// FinalizingPolicy define the behavior of controller when phase enter Finalizing
// Defaults to "Immediate"
FinalizingPolicy FinalizingPolicyType `json:"finalizingPolicy,omitempty"`
// PatchPodTemplateMetadata indicates patch configuration(e.g. labels, annotations) to the canary deployment podTemplateSpec.metadata
// only support for canary deployment
// +optional
PatchPodTemplateMetadata *PatchPodTemplateMetadata `json:"patchPodTemplateMetadata,omitempty"`
}
type FinalizingPolicyType string

View File

@ -51,6 +51,12 @@ const (
// Defaults to "canary" to Deployment.
// Defaults to "partition" to the others.
RolloutStyleAnnotation = "rollouts.kruise.io/rolling-style"
// TrafficRoutingAnnotation is the TrafficRouting Name, and it is the Rollout's TrafficRouting.
// The Rollout release will trigger the TrafficRouting release. For example:
// A microservice consists of three applications, and the invocation relationship is as follows: a -> b -> c,
// and application(a, b, c)'s gateway is trafficRouting. Any application(a, b or b) release will trigger TrafficRouting release.
TrafficRoutingAnnotation = "rollouts.kruise.io/trafficrouting"
)
// RolloutSpec defines the desired state of Rollout
@ -66,25 +72,18 @@ type RolloutSpec struct {
// RolloutID should be changed before each workload revision publication.
// It is to distinguish consecutive multiple workload publications and rollout progress.
DeprecatedRolloutID string `json:"rolloutID,omitempty"`
// if a rollout disabled, then the rollout would not watch changes of workload
//+kubebuilder:validation:Optional
//+kubebuilder:default=false
Disabled bool `json:"disabled"`
}
type ObjectRef struct {
// WorkloadRef contains enough information to let you identify a workload for Rollout
// Batch release of the bypass
WorkloadRef *WorkloadRef `json:"workloadRef,omitempty"`
// revisionRef
// Fully managed batch publishing capability
//RevisionRef *ControllerRevisionRef `json:"revisionRef,omitempty"`
}
type ObjectRefType string
const (
WorkloadRefType = "workloadRef"
RevisionRefType = "revisionRef"
)
// WorkloadRef holds a references to the Kubernetes object
type WorkloadRef struct {
// API Version of the referent
@ -102,50 +101,44 @@ type RolloutStrategy struct {
Paused bool `json:"paused,omitempty"`
// +optional
Canary *CanaryStrategy `json:"canary,omitempty"`
// +optional
// BlueGreen *BlueGreenStrategy `json:"blueGreen,omitempty"`
}
type RolloutStrategyType string
const (
RolloutStrategyCanary RolloutStrategyType = "canary"
RolloutStrategyBlueGreen RolloutStrategyType = "blueGreen"
)
// CanaryStrategy defines parameters for a Replica Based Canary
type CanaryStrategy struct {
// Steps define the order of phases to execute release in batches(20%, 40%, 60%, 80%, 100%)
// +optional
Steps []CanaryStep `json:"steps,omitempty"`
// TrafficRoutings hosts all the supported service meshes supported to enable more fine-grained traffic routing
// todo current only support one TrafficRouting
TrafficRoutings []*TrafficRouting `json:"trafficRoutings,omitempty"`
// and current only support one TrafficRouting
TrafficRoutings []TrafficRoutingRef `json:"trafficRoutings,omitempty"`
// FailureThreshold indicates how many failed pods can be tolerated in all upgraded pods.
// Only when FailureThreshold are satisfied, Rollout can enter ready state.
// If FailureThreshold is nil, Rollout will use the MaxUnavailable of workload as its
// FailureThreshold.
// Defaults to nil.
FailureThreshold *intstr.IntOrString `json:"failureThreshold,omitempty"`
// MetricsAnalysis *MetricsAnalysisBackground `json:"metricsAnalysis,omitempty"`
// PatchPodTemplateMetadata indicates patch configuration(e.g. labels, annotations) to the canary deployment podTemplateSpec.metadata
// only support for canary deployment
// +optional
PatchPodTemplateMetadata *PatchPodTemplateMetadata `json:"patchPodTemplateMetadata,omitempty"`
}
type PatchPodTemplateMetadata struct {
// annotations
Annotations map[string]string `json:"annotations,omitempty"`
// labels
Labels map[string]string `json:"labels,omitempty"`
}
// CanaryStep defines a step of a canary workload.
type CanaryStep struct {
// Weight indicate how many percentage of traffic the canary pods should receive
// +optional
Weight *int32 `json:"weight,omitempty"`
TrafficRoutingStrategy `json:",inline"`
// Replicas is the number of expected canary pods in this batch
// it can be an absolute number (ex: 5) or a percentage of total pods.
Replicas *intstr.IntOrString `json:"replicas,omitempty"`
// Pause defines a pause stage for a rollout, manual or auto
// +optional
Pause RolloutPause `json:"pause,omitempty"`
// Matches define conditions used for matching the incoming HTTP requests to canary service.
// Each match is independent, i.e. this rule will be matched if **any** one of the matches is satisfied.
// If Gateway API, current only support one match.
// And cannot support both weight and matches, if both are configured, then matches takes precedence.
Matches []HttpRouteMatch `json:"matches,omitempty"`
}
type HttpRouteMatch struct {
@ -163,37 +156,6 @@ type RolloutPause struct {
Duration *int32 `json:"duration,omitempty"`
}
// TrafficRouting hosts all the different configuration for supported service meshes to enable more fine-grained traffic routing
type TrafficRouting struct {
// Service holds the name of a service which selects pods with stable version and don't select any pods with canary version.
Service string `json:"service"`
// Optional duration in seconds the traffic provider(e.g. nginx ingress controller) consumes the service, ingress configuration changes gracefully.
GracePeriodSeconds int32 `json:"gracePeriodSeconds,omitempty"`
// Ingress holds Ingress specific configuration to route traffic, e.g. Nginx, Alb.
Ingress *IngressTrafficRouting `json:"ingress,omitempty"`
// Gateway holds Gateway specific configuration to route traffic
// Gateway configuration only supports >= v0.4.0 (v1alpha2).
Gateway *GatewayTrafficRouting `json:"gateway,omitempty"`
}
// IngressTrafficRouting configuration for ingress controller to control traffic routing
type IngressTrafficRouting struct {
// ClassType refers to the type of `Ingress`.
// current support nginx, aliyun-alb. default is nginx.
// +optional
ClassType string `json:"classType,omitempty"`
// Name refers to the name of an `Ingress` resource in the same namespace as the `Rollout`
Name string `json:"name"`
}
// GatewayTrafficRouting configuration for gateway api
type GatewayTrafficRouting struct {
// HTTPRouteName refers to the name of an `HTTPRoute` resource in the same namespace as the `Rollout`
HTTPRouteName *string `json:"httpRouteName,omitempty"`
// TCPRouteName *string `json:"tcpRouteName,omitempty"`
// UDPRouteName *string `json:"udpRouteName,omitempty"`
}
// RolloutStatus defines the observed state of Rollout
type RolloutStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
@ -310,6 +272,10 @@ const (
RolloutPhaseProgressing RolloutPhase = "Progressing"
// RolloutPhaseTerminating indicates a rollout is terminated
RolloutPhaseTerminating RolloutPhase = "Terminating"
// RolloutPhaseDisabled indicates a rollout is disabled
RolloutPhaseDisabled RolloutPhase = "Disabled"
// RolloutPhaseDisabling indicates a rollout is disabling and releasing resources
RolloutPhaseDisabling RolloutPhase = "Disabling"
)
// +genclient

View File

@ -0,0 +1,154 @@
/*
Copyright 2023 The Kruise Authors.
Licensed 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 v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)
const (
ProgressingRolloutFinalizerPrefix = "progressing.rollouts.kruise.io"
)
// TrafficRoutingRef hosts all the different configuration for supported service meshes to enable more fine-grained traffic routing
type TrafficRoutingRef struct {
// Service holds the name of a service which selects pods with stable version and don't select any pods with canary version.
Service string `json:"service"`
// Optional duration in seconds the traffic provider(e.g. nginx ingress controller) consumes the service, ingress configuration changes gracefully.
GracePeriodSeconds int32 `json:"gracePeriodSeconds,omitempty"`
// Ingress holds Ingress specific configuration to route traffic, e.g. Nginx, Alb.
Ingress *IngressTrafficRouting `json:"ingress,omitempty"`
// Gateway holds Gateway specific configuration to route traffic
// Gateway configuration only supports >= v0.4.0 (v1alpha2).
Gateway *GatewayTrafficRouting `json:"gateway,omitempty"`
}
// IngressTrafficRouting configuration for ingress controller to control traffic routing
type IngressTrafficRouting struct {
// ClassType refers to the type of `Ingress`.
// current support nginx, aliyun-alb. default is nginx.
// +optional
ClassType string `json:"classType,omitempty"`
// Name refers to the name of an `Ingress` resource in the same namespace as the `Rollout`
Name string `json:"name"`
}
// GatewayTrafficRouting configuration for gateway api
type GatewayTrafficRouting struct {
// HTTPRouteName refers to the name of an `HTTPRoute` resource in the same namespace as the `Rollout`
HTTPRouteName *string `json:"httpRouteName,omitempty"`
// TCPRouteName *string `json:"tcpRouteName,omitempty"`
// UDPRouteName *string `json:"udpRouteName,omitempty"`
}
type TrafficRoutingSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// ObjectRef indicates trafficRouting ref
ObjectRef []TrafficRoutingRef `json:"objectRef"`
// trafficrouting strategy
Strategy TrafficRoutingStrategy `json:"strategy"`
}
type TrafficRoutingStrategy struct {
// Weight indicate how many percentage of traffic the canary pods should receive
// +optional
Weight *int32 `json:"weight,omitempty"`
// Set overwrites the request with the given header (name, value)
// before the action.
//
// Input:
// GET /foo HTTP/1.1
// my-header: foo
//
// requestHeaderModifier:
// set:
// - name: "my-header"
// value: "bar"
//
// Output:
// GET /foo HTTP/1.1
// my-header: bar
//
// +optional
RequestHeaderModifier *gatewayv1alpha2.HTTPRequestHeaderFilter `json:"requestHeaderModifier,omitempty"`
// Matches define conditions used for matching the incoming HTTP requests to canary service.
// Each match is independent, i.e. this rule will be matched if **any** one of the matches is satisfied.
// If Gateway API, current only support one match.
// And cannot support both weight and matches, if both are configured, then matches takes precedence.
Matches []HttpRouteMatch `json:"matches,omitempty"`
}
type TrafficRoutingStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// observedGeneration is the most recent generation observed for this Rollout.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Phase is the trafficRouting phase.
Phase TrafficRoutingPhase `json:"phase,omitempty"`
// Message provides details on why the rollout is in its current phase
Message string `json:"message,omitempty"`
}
// TrafficRoutingPhase are a set of phases that this rollout
type TrafficRoutingPhase string
const (
// TrafficRoutingPhaseInitial indicates a traffic routing is Initial
TrafficRoutingPhaseInitial TrafficRoutingPhase = "Initial"
// TrafficRoutingPhaseHealthy indicates a traffic routing is healthy.
// This means that Ingress and Service Resources exist.
TrafficRoutingPhaseHealthy TrafficRoutingPhase = "Healthy"
// TrafficRoutingPhaseProgressing indicates a traffic routing is not yet healthy but still making progress towards a healthy state
TrafficRoutingPhaseProgressing TrafficRoutingPhase = "Progressing"
// TrafficRoutingPhaseFinalizing indicates the trafficRouting progress is complete, and is running recycle operations.
TrafficRoutingPhaseFinalizing TrafficRoutingPhase = "Finalizing"
// TrafficRoutingPhaseTerminating indicates a traffic routing is terminated
TrafficRoutingPhaseTerminating TrafficRoutingPhase = "Terminating"
)
// +genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.phase",description="The TrafficRouting status phase"
// +kubebuilder:printcolumn:name="MESSAGE",type="string",JSONPath=".status.message",description="The TrafficRouting canary status message"
// +kubebuilder:printcolumn:name="AGE",type=date,JSONPath=".metadata.creationTimestamp"
// TrafficRouting is the Schema for the TrafficRoutings API
type TrafficRouting struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TrafficRoutingSpec `json:"spec,omitempty"`
Status TrafficRoutingStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// TrafficRoutingList contains a list of TrafficRouting
type TrafficRoutingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TrafficRouting `json:"items"`
}
func init() {
SchemeBuilder.Register(&TrafficRouting{}, &TrafficRoutingList{})
}

View File

@ -178,24 +178,13 @@ func (in *CanaryStatus) DeepCopy() *CanaryStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CanaryStep) DeepCopyInto(out *CanaryStep) {
*out = *in
if in.Weight != nil {
in, out := &in.Weight, &out.Weight
*out = new(int32)
**out = **in
}
in.TrafficRoutingStrategy.DeepCopyInto(&out.TrafficRoutingStrategy)
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(intstr.IntOrString)
**out = **in
}
in.Pause.DeepCopyInto(&out.Pause)
if in.Matches != nil {
in, out := &in.Matches, &out.Matches
*out = make([]HttpRouteMatch, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryStep.
@ -240,13 +229,9 @@ func (in *CanaryStrategy) DeepCopyInto(out *CanaryStrategy) {
}
if in.TrafficRoutings != nil {
in, out := &in.TrafficRoutings, &out.TrafficRoutings
*out = make([]*TrafficRouting, len(*in))
*out = make([]TrafficRoutingRef, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(TrafficRouting)
(*in).DeepCopyInto(*out)
}
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.FailureThreshold != nil {
@ -254,6 +239,11 @@ func (in *CanaryStrategy) DeepCopyInto(out *CanaryStrategy) {
*out = new(intstr.IntOrString)
**out = **in
}
if in.PatchPodTemplateMetadata != nil {
in, out := &in.PatchPodTemplateMetadata, &out.PatchPodTemplateMetadata
*out = new(PatchPodTemplateMetadata)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryStrategy.
@ -427,6 +417,35 @@ func (in *ObjectRef) DeepCopy() *ObjectRef {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PatchPodTemplateMetadata) DeepCopyInto(out *PatchPodTemplateMetadata) {
*out = *in
if in.Annotations != nil {
in, out := &in.Annotations, &out.Annotations
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PatchPodTemplateMetadata.
func (in *PatchPodTemplateMetadata) DeepCopy() *PatchPodTemplateMetadata {
if in == nil {
return nil
}
out := new(PatchPodTemplateMetadata)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Pod) DeepCopyInto(out *Pod) {
*out = *in
@ -476,6 +495,11 @@ func (in *ReleasePlan) DeepCopyInto(out *ReleasePlan) {
*out = new(intstr.IntOrString)
**out = **in
}
if in.PatchPodTemplateMetadata != nil {
in, out := &in.PatchPodTemplateMetadata, &out.PatchPodTemplateMetadata
*out = new(PatchPodTemplateMetadata)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReleasePlan.
@ -783,16 +807,10 @@ func (in *ServiceInfo) DeepCopy() *ServiceInfo {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRouting) DeepCopyInto(out *TrafficRouting) {
*out = *in
if in.Ingress != nil {
in, out := &in.Ingress, &out.Ingress
*out = new(IngressTrafficRouting)
**out = **in
}
if in.Gateway != nil {
in, out := &in.Gateway, &out.Gateway
*out = new(GatewayTrafficRouting)
(*in).DeepCopyInto(*out)
}
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRouting.
@ -805,6 +823,14 @@ func (in *TrafficRouting) DeepCopy() *TrafficRouting {
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TrafficRouting) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingInfo) DeepCopyInto(out *TrafficRoutingInfo) {
*out = *in
@ -830,6 +856,133 @@ func (in *TrafficRoutingInfo) DeepCopy() *TrafficRoutingInfo {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingList) DeepCopyInto(out *TrafficRoutingList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TrafficRouting, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRoutingList.
func (in *TrafficRoutingList) DeepCopy() *TrafficRoutingList {
if in == nil {
return nil
}
out := new(TrafficRoutingList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TrafficRoutingList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingRef) DeepCopyInto(out *TrafficRoutingRef) {
*out = *in
if in.Ingress != nil {
in, out := &in.Ingress, &out.Ingress
*out = new(IngressTrafficRouting)
**out = **in
}
if in.Gateway != nil {
in, out := &in.Gateway, &out.Gateway
*out = new(GatewayTrafficRouting)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRoutingRef.
func (in *TrafficRoutingRef) DeepCopy() *TrafficRoutingRef {
if in == nil {
return nil
}
out := new(TrafficRoutingRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingSpec) DeepCopyInto(out *TrafficRoutingSpec) {
*out = *in
if in.ObjectRef != nil {
in, out := &in.ObjectRef, &out.ObjectRef
*out = make([]TrafficRoutingRef, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
in.Strategy.DeepCopyInto(&out.Strategy)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRoutingSpec.
func (in *TrafficRoutingSpec) DeepCopy() *TrafficRoutingSpec {
if in == nil {
return nil
}
out := new(TrafficRoutingSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingStatus) DeepCopyInto(out *TrafficRoutingStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRoutingStatus.
func (in *TrafficRoutingStatus) DeepCopy() *TrafficRoutingStatus {
if in == nil {
return nil
}
out := new(TrafficRoutingStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TrafficRoutingStrategy) DeepCopyInto(out *TrafficRoutingStrategy) {
*out = *in
if in.Weight != nil {
in, out := &in.Weight, &out.Weight
*out = new(int32)
**out = **in
}
if in.RequestHeaderModifier != nil {
in, out := &in.RequestHeaderModifier, &out.RequestHeaderModifier
*out = new(v1alpha2.HTTPRequestHeaderFilter)
(*in).DeepCopyInto(*out)
}
if in.Matches != nil {
in, out := &in.Matches, &out.Matches
*out = make([]HttpRouteMatch, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficRoutingStrategy.
func (in *TrafficRoutingStrategy) DeepCopy() *TrafficRoutingStrategy {
if in == nil {
return nil
}
out := new(TrafficRoutingStrategy)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadInfo) DeepCopyInto(out *WorkloadInfo) {
*out = *in

56
utils/scheme/scheme.go Normal file
View File

@ -0,0 +1,56 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed 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 scheme
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// Builder builds a new Scheme for mapping go types to Kubernetes GroupVersionKinds.
type Builder struct {
GroupVersion schema.GroupVersion
runtime.SchemeBuilder
}
// Register adds one or objects to the SchemeBuilder so they can be added to a Scheme. Register mutates bld.
func (bld *Builder) Register(object ...runtime.Object) *Builder {
bld.SchemeBuilder.Register(func(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(bld.GroupVersion, object...)
metav1.AddToGroupVersion(scheme, bld.GroupVersion)
return nil
})
return bld
}
// RegisterAll registers all types from the Builder argument. RegisterAll mutates bld.
func (bld *Builder) RegisterAll(b *Builder) *Builder {
bld.SchemeBuilder = append(bld.SchemeBuilder, b.SchemeBuilder...)
return bld
}
// AddToScheme adds all registered types to s.
func (bld *Builder) AddToScheme(s *runtime.Scheme) error {
return bld.SchemeBuilder.AddToScheme(s)
}
// Build returns a new Scheme containing the registered types.
func (bld *Builder) Build() (*runtime.Scheme, error) {
s := runtime.NewScheme()
return s, bld.AddToScheme(s)
}