use istio client-go library instead of knative (#1661)
use istio client-go library instead of knative bump kubernetes dependency version change code coverage to codecov
This commit is contained in:
98
vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go
generated
vendored
98
vendor/sigs.k8s.io/controller-runtime/pkg/client/unstructured_client.go
generated
vendored
@@ -37,16 +37,18 @@ type unstructuredClient struct {
|
||||
}
|
||||
|
||||
// Create implements client.Client
|
||||
func (uc *unstructuredClient) Create(_ context.Context, obj runtime.Object) error {
|
||||
func (uc *unstructuredClient) Create(_ context.Context, obj runtime.Object, opts ...CreateOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
}
|
||||
createOpts := CreateOptions{}
|
||||
createOpts.ApplyOptions(opts)
|
||||
r, err := uc.getResourceInterface(u.GroupVersionKind(), u.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i, err := r.Create(u, metav1.CreateOptions{})
|
||||
i, err := r.Create(u, *createOpts.AsCreateOptions())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -55,16 +57,18 @@ func (uc *unstructuredClient) Create(_ context.Context, obj runtime.Object) erro
|
||||
}
|
||||
|
||||
// Update implements client.Client
|
||||
func (uc *unstructuredClient) Update(_ context.Context, obj runtime.Object) error {
|
||||
func (uc *unstructuredClient) Update(_ context.Context, obj runtime.Object, opts ...UpdateOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
}
|
||||
updateOpts := UpdateOptions{}
|
||||
updateOpts.ApplyOptions(opts)
|
||||
r, err := uc.getResourceInterface(u.GroupVersionKind(), u.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i, err := r.Update(u, metav1.UpdateOptions{})
|
||||
i, err := r.Update(u, *updateOpts.AsUpdateOptions())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,7 +77,7 @@ func (uc *unstructuredClient) Update(_ context.Context, obj runtime.Object) erro
|
||||
}
|
||||
|
||||
// Delete implements client.Client
|
||||
func (uc *unstructuredClient) Delete(_ context.Context, obj runtime.Object, opts ...DeleteOptionFunc) error {
|
||||
func (uc *unstructuredClient) Delete(_ context.Context, obj runtime.Object, opts ...DeleteOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
@@ -83,10 +87,53 @@ func (uc *unstructuredClient) Delete(_ context.Context, obj runtime.Object, opts
|
||||
return err
|
||||
}
|
||||
deleteOpts := DeleteOptions{}
|
||||
err = r.Delete(u.GetName(), deleteOpts.ApplyOptions(opts).AsDeleteOptions())
|
||||
deleteOpts.ApplyOptions(opts)
|
||||
err = r.Delete(u.GetName(), deleteOpts.AsDeleteOptions())
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteAllOf implements client.Client
|
||||
func (uc *unstructuredClient) DeleteAllOf(_ context.Context, obj runtime.Object, opts ...DeleteAllOfOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
}
|
||||
r, err := uc.getResourceInterface(u.GroupVersionKind(), u.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
deleteAllOfOpts := DeleteAllOfOptions{}
|
||||
deleteAllOfOpts.ApplyOptions(opts)
|
||||
err = r.DeleteCollection(deleteAllOfOpts.AsDeleteOptions(), *deleteAllOfOpts.AsListOptions())
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch implements client.Client
|
||||
func (uc *unstructuredClient) Patch(_ context.Context, obj runtime.Object, patch Patch, opts ...PatchOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
}
|
||||
r, err := uc.getResourceInterface(u.GroupVersionKind(), u.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := patch.Data(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
patchOpts := &PatchOptions{}
|
||||
i, err := r.Patch(u.GetName(), patch.Type(), data, *patchOpts.ApplyOptions(opts).AsPatchOptions())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.Object = i.Object
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get implements client.Client
|
||||
func (uc *unstructuredClient) Get(_ context.Context, key ObjectKey, obj runtime.Object) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
@@ -106,7 +153,7 @@ func (uc *unstructuredClient) Get(_ context.Context, key ObjectKey, obj runtime.
|
||||
}
|
||||
|
||||
// List implements client.Client
|
||||
func (uc *unstructuredClient) List(_ context.Context, opts *ListOptions, obj runtime.Object) error {
|
||||
func (uc *unstructuredClient) List(_ context.Context, obj runtime.Object, opts ...ListOption) error {
|
||||
u, ok := obj.(*unstructured.UnstructuredList)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
@@ -115,16 +162,14 @@ func (uc *unstructuredClient) List(_ context.Context, opts *ListOptions, obj run
|
||||
if strings.HasSuffix(gvk.Kind, "List") {
|
||||
gvk.Kind = gvk.Kind[:len(gvk.Kind)-4]
|
||||
}
|
||||
namespace := ""
|
||||
if opts != nil {
|
||||
namespace = opts.Namespace
|
||||
}
|
||||
r, err := uc.getResourceInterface(gvk, namespace)
|
||||
listOpts := ListOptions{}
|
||||
listOpts.ApplyOptions(opts)
|
||||
r, err := uc.getResourceInterface(gvk, listOpts.Namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i, err := r.List(*opts.AsListOptions())
|
||||
i, err := r.List(*listOpts.AsListOptions())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -133,7 +178,7 @@ func (uc *unstructuredClient) List(_ context.Context, opts *ListOptions, obj run
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uc *unstructuredClient) UpdateStatus(_ context.Context, obj runtime.Object) error {
|
||||
func (uc *unstructuredClient) UpdateStatus(_ context.Context, obj runtime.Object, opts ...UpdateOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
@@ -142,7 +187,30 @@ func (uc *unstructuredClient) UpdateStatus(_ context.Context, obj runtime.Object
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i, err := r.UpdateStatus(u, metav1.UpdateOptions{})
|
||||
i, err := r.UpdateStatus(u, *(&UpdateOptions{}).ApplyOptions(opts).AsUpdateOptions())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.Object = i.Object
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uc *unstructuredClient) PatchStatus(_ context.Context, obj runtime.Object, patch Patch, opts ...PatchOption) error {
|
||||
u, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return fmt.Errorf("unstructured client did not understand object: %T", obj)
|
||||
}
|
||||
r, err := uc.getResourceInterface(u.GroupVersionKind(), u.GetNamespace())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := patch.Data(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i, err := r.Patch(u.GetName(), patch.Type(), data, *(&PatchOptions{}).ApplyOptions(opts).AsPatchOptions(), "status")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user