Skip to content

Commit

Permalink
Support patch (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mir Shahriar authored and tamalsaha committed Aug 22, 2017
1 parent 5a24994 commit 8b5e9ea
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 23 deletions.
15 changes: 15 additions & 0 deletions client/clientset/cluster_alert.go
Expand Up @@ -3,6 +3,7 @@ package clientset
import (
aci "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)
Expand All @@ -19,6 +20,7 @@ type ClusterAlertInterface interface {
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
UpdateStatus(ClusterAlert *aci.ClusterAlert) (*aci.ClusterAlert, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*aci.ClusterAlert, error)
}

type ClusterAlertImpl struct {
Expand Down Expand Up @@ -107,3 +109,16 @@ func (c *ClusterAlertImpl) UpdateStatus(alert *aci.ClusterAlert) (result *aci.Cl
Into(result)
return
}

func (c *ClusterAlertImpl) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *aci.ClusterAlert, err error) {
result = &aci.ClusterAlert{}
err = c.r.Patch(pt).
Namespace(c.ns).
Resource(aci.ResourceTypeClusterAlert).
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
11 changes: 11 additions & 0 deletions client/clientset/fake/cluster_alert.go
Expand Up @@ -4,6 +4,7 @@ import (
tapi "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)
Expand Down Expand Up @@ -92,3 +93,13 @@ func (mock *FakeClusterAlert) Watch(opts metav1.ListOptions) (watch.Interface, e
return mock.Fake.
InvokesWatch(testing.NewWatchAction(resourceClusterAlert, mock.ns, opts))
}

func (mock *FakeClusterAlert) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*tapi.ClusterAlert, error) {
obj, err := mock.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceClusterAlert, mock.ns, name, data, subresources...), &tapi.ClusterAlert{})

if obj == nil {
return nil, err
}
return obj.(*tapi.ClusterAlert), err
}
11 changes: 11 additions & 0 deletions client/clientset/fake/node_alert.go
Expand Up @@ -4,6 +4,7 @@ import (
tapi "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)
Expand Down Expand Up @@ -92,3 +93,13 @@ func (mock *FakeNodeAlert) Watch(opts metav1.ListOptions) (watch.Interface, erro
return mock.Fake.
InvokesWatch(testing.NewWatchAction(resourceNodeAlert, mock.ns, opts))
}

func (mock *FakeNodeAlert) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*tapi.NodeAlert, error) {
obj, err := mock.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceNodeAlert, mock.ns, name, data, subresources...), &tapi.NodeAlert{})

if obj == nil {
return nil, err
}
return obj.(*tapi.NodeAlert), err
}
11 changes: 11 additions & 0 deletions client/clientset/fake/pod_alert.go
Expand Up @@ -4,6 +4,7 @@ import (
tapi "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)
Expand Down Expand Up @@ -92,3 +93,13 @@ func (mock *FakePodAlert) Watch(opts metav1.ListOptions) (watch.Interface, error
return mock.Fake.
InvokesWatch(testing.NewWatchAction(resourcePodAlert, mock.ns, opts))
}

func (mock *FakePodAlert) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*tapi.PodAlert, error) {
obj, err := mock.Fake.
Invokes(testing.NewPatchSubresourceAction(resourcePodAlert, mock.ns, name, data, subresources...), &tapi.PodAlert{})

if obj == nil {
return nil, err
}
return obj.(*tapi.PodAlert), err
}
15 changes: 15 additions & 0 deletions client/clientset/node_alert.go
Expand Up @@ -3,6 +3,7 @@ package clientset
import (
aci "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)
Expand All @@ -19,6 +20,7 @@ type NodeAlertInterface interface {
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
UpdateStatus(NodeAlert *aci.NodeAlert) (*aci.NodeAlert, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*aci.NodeAlert, error)
}

type NodeAlertImpl struct {
Expand Down Expand Up @@ -107,3 +109,16 @@ func (c *NodeAlertImpl) UpdateStatus(alert *aci.NodeAlert) (result *aci.NodeAler
Into(result)
return
}

func (c *NodeAlertImpl) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *aci.NodeAlert, err error) {
result = &aci.NodeAlert{}
err = c.r.Patch(pt).
Namespace(c.ns).
Resource(aci.ResourceTypeNodeAlert).
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
61 changes: 38 additions & 23 deletions client/clientset/pod_alert.go
@@ -1,8 +1,9 @@
package clientset

import (
tapi "github.com/appscode/searchlight/api"
aci "github.com/appscode/searchlight/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)
Expand All @@ -12,13 +13,14 @@ type PodAlertGetter interface {
}

type PodAlertInterface interface {
List(opts metav1.ListOptions) (*tapi.PodAlertList, error)
Get(name string) (*tapi.PodAlert, error)
Create(Alert *tapi.PodAlert) (*tapi.PodAlert, error)
Update(Alert *tapi.PodAlert) (*tapi.PodAlert, error)
List(opts metav1.ListOptions) (*aci.PodAlertList, error)
Get(name string) (*aci.PodAlert, error)
Create(Alert *aci.PodAlert) (*aci.PodAlert, error)
Update(Alert *aci.PodAlert) (*aci.PodAlert, error)
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
UpdateStatus(Alert *tapi.PodAlert) (*tapi.PodAlert, error)
UpdateStatus(Alert *aci.PodAlert) (*aci.PodAlert, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*aci.PodAlert, error)
}

type PodAlertImpl struct {
Expand All @@ -32,44 +34,44 @@ func newPodAlert(c *ExtensionClient, namespace string) *PodAlertImpl {
return &PodAlertImpl{c.restClient, namespace}
}

func (c *PodAlertImpl) List(opts metav1.ListOptions) (result *tapi.PodAlertList, err error) {
result = &tapi.PodAlertList{}
func (c *PodAlertImpl) List(opts metav1.ListOptions) (result *aci.PodAlertList, err error) {
result = &aci.PodAlertList{}
err = c.r.Get().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
VersionedParams(&opts, ExtendedCodec).
Do().
Into(result)
return
}

func (c *PodAlertImpl) Get(name string) (result *tapi.PodAlert, err error) {
result = &tapi.PodAlert{}
func (c *PodAlertImpl) Get(name string) (result *aci.PodAlert, err error) {
result = &aci.PodAlert{}
err = c.r.Get().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
Name(name).
Do().
Into(result)
return
}

func (c *PodAlertImpl) Create(alert *tapi.PodAlert) (result *tapi.PodAlert, err error) {
result = &tapi.PodAlert{}
func (c *PodAlertImpl) Create(alert *aci.PodAlert) (result *aci.PodAlert, err error) {
result = &aci.PodAlert{}
err = c.r.Post().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
Body(alert).
Do().
Into(result)
return
}

func (c *PodAlertImpl) Update(alert *tapi.PodAlert) (result *tapi.PodAlert, err error) {
result = &tapi.PodAlert{}
func (c *PodAlertImpl) Update(alert *aci.PodAlert) (result *aci.PodAlert, err error) {
result = &aci.PodAlert{}
err = c.r.Put().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
Name(alert.Name).
Body(alert).
Do().
Expand All @@ -80,7 +82,7 @@ func (c *PodAlertImpl) Update(alert *tapi.PodAlert) (result *tapi.PodAlert, err
func (c *PodAlertImpl) Delete(name string) (err error) {
return c.r.Delete().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
Name(name).
Do().
Error()
Expand All @@ -90,20 +92,33 @@ func (c *PodAlertImpl) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.r.Get().
Prefix("watch").
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
VersionedParams(&opts, ExtendedCodec).
Watch()
}

func (c *PodAlertImpl) UpdateStatus(alert *tapi.PodAlert) (result *tapi.PodAlert, err error) {
result = &tapi.PodAlert{}
func (c *PodAlertImpl) UpdateStatus(alert *aci.PodAlert) (result *aci.PodAlert, err error) {
result = &aci.PodAlert{}
err = c.r.Put().
Namespace(c.ns).
Resource(tapi.ResourceTypePodAlert).
Resource(aci.ResourceTypePodAlert).
Name(alert.Name).
SubResource("status").
Body(alert).
Do().
Into(result)
return
}

func (c *PodAlertImpl) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *aci.PodAlert, err error) {
result = &aci.PodAlert{}
err = c.r.Patch(pt).
Namespace(c.ns).
Resource(aci.ResourceTypePodAlert).
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

0 comments on commit 8b5e9ea

Please sign in to comment.