mirror of
https://github.com/niusmallnan/steve.git
synced 2025-09-08 16:39:36 +00:00
Support JSON patch
This commit is contained in:
20
vendor/github.com/rancher/norman/pkg/store/proxy/proxy_store.go
generated
vendored
20
vendor/github.com/rancher/norman/pkg/store/proxy/proxy_store.go
generated
vendored
@@ -7,18 +7,15 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
types2 "k8s.io/apimachinery/pkg/types"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/rancher/norman/pkg/types/convert"
|
|
||||||
|
|
||||||
errors2 "github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/rancher/norman/pkg/types"
|
"github.com/rancher/norman/pkg/types"
|
||||||
|
"github.com/rancher/norman/pkg/types/convert"
|
||||||
"github.com/rancher/norman/pkg/types/values"
|
"github.com/rancher/norman/pkg/types/values"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
|
apitypes "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
)
|
)
|
||||||
@@ -147,7 +144,7 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
|||||||
Limit: 1,
|
Limit: 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnErr(errors2.Wrapf(err, "failed to list %s", schema.ID), result)
|
returnErr(errors.Wrapf(err, "failed to list %s", schema.ID), result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rev = list.GetResourceVersion()
|
rev = list.GetResourceVersion()
|
||||||
@@ -160,7 +157,7 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
|||||||
ResourceVersion: rev,
|
ResourceVersion: rev,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnErr(errors2.Wrapf(err, "stopping watch for %s: %v", schema.ID), result)
|
returnErr(errors.Wrapf(err, "stopping watch for %s: %v", schema.ID), result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer watcher.Stop()
|
defer watcher.Stop()
|
||||||
@@ -271,7 +268,12 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.Schema, params typ
|
|||||||
return types.APIObject{}, err
|
return types.APIObject{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := k8sClient.Patch(id, types2.StrategicMergePatchType, bytes, metav1.PatchOptions{})
|
pType := apitypes.StrategicMergePatchType
|
||||||
|
if apiOp.Request.Header.Get("content-type") == "application/json-patch+json" {
|
||||||
|
pType = apitypes.JSONPatchType
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := k8sClient.Patch(id, pType, bytes, metav1.PatchOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.APIObject{}, err
|
return types.APIObject{}, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user