Skip to content

Commit

Permalink
Add Patch API Supports (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadlil authored and tamalsaha committed Aug 22, 2017
1 parent 7615c66 commit 1bccec9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
15 changes: 15 additions & 0 deletions client/clientset/certificate.go
Expand Up @@ -3,6 +3,7 @@ package clientset
import (
tapi "github.com/appscode/voyager/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)
Expand All @@ -19,6 +20,7 @@ type CertificateInterface interface {
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
UpdateStatus(certificate *tapi.Certificate) (*tapi.Certificate, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*tapi.Certificate, error)
}

type CertificateImpl struct {
Expand Down Expand Up @@ -107,3 +109,16 @@ func (c *CertificateImpl) UpdateStatus(certificate *tapi.Certificate) (result *t
Into(result)
return
}

func (c *CertificateImpl) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *tapi.Certificate, err error) {
result = &tapi.Certificate{}
err = c.r.Patch(pt).
Namespace(c.ns).
Resource(tapi.ResourceTypeCertificate).
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
9 changes: 9 additions & 0 deletions client/clientset/fake/certificate.go
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/appscode/voyager/client/clientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)
Expand Down Expand Up @@ -95,3 +96,11 @@ func (mock *FakeCertificate) Watch(opts metav1.ListOptions) (watch.Interface, er
return mock.Fake.
InvokesWatch(testing.NewWatchAction(certResource, mock.ns, opts))
}

func (mock *FakeCertificate) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *tapi.Certificate, err error) {
obj, err := mock.Fake.Invokes(testing.NewPatchSubresourceAction(certResource, mock.ns, name, data, subresources...), &tapi.Certificate{})
if obj == nil {
return nil, err
}
return obj.(*tapi.Certificate), err
}
9 changes: 9 additions & 0 deletions client/clientset/fake/ingress.go
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/appscode/voyager/client/clientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)
Expand Down Expand Up @@ -95,3 +96,11 @@ func (mock *FakeIngress) Watch(opts metav1.ListOptions) (watch.Interface, error)
return mock.Fake.
InvokesWatch(testing.NewWatchAction(ingressResource, mock.ns, opts))
}

func (mock *FakeIngress) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *tapi.Ingress, err error) {
obj, err := mock.Fake.Invokes(testing.NewPatchSubresourceAction(ingressResource, mock.ns, name, data, subresources...), &tapi.Ingress{})
if obj == nil {
return nil, err
}
return obj.(*tapi.Ingress), err
}
15 changes: 15 additions & 0 deletions client/clientset/ingress.go
Expand Up @@ -3,6 +3,7 @@ package clientset
import (
tapi "github.com/appscode/voyager/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
)
Expand All @@ -21,6 +22,7 @@ type IngressInterface interface {
Delete(name string) error
Watch(opts metav1.ListOptions) (watch.Interface, error)
UpdateStatus(ExtendedIngress *tapi.Ingress) (*tapi.Ingress, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*tapi.Ingress, error)
}

// IngressImpl implements IngressesGetter interface
Expand Down Expand Up @@ -118,3 +120,16 @@ func (c *IngressImpl) UpdateStatus(extendedIngress *tapi.Ingress) (result *tapi.
Into(result)
return
}

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

0 comments on commit 1bccec9

Please sign in to comment.