1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-16 15:29:04 +00:00

added values overwrite check

This commit is contained in:
gehrkefc
2024-09-02 23:46:29 -03:00
parent 0fcf47917b
commit 93489619a8

View File

@@ -432,7 +432,15 @@ func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params
}
gvk := attributes.GVK(schema)
input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind()
apiVersion, kind := gvk.ToAPIVersionAndKind()
if value, found := input["apiVersion"]; !found || value == "" {
input["apiVersion"] = apiVersion
}
if value, found := input["kind"]; !found || value == "" {
input["kind"] = kind
}
buffer := WarningBuffer{}
k8sClient, err := metricsStore.Wrap(s.clientGetter.TableClient(apiOp, schema, ns, &buffer))
@@ -506,7 +514,15 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params
}
gvk := attributes.GVK(schema)
input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind()
apiVersion, kind := gvk.ToAPIVersionAndKind()
if value, found := input["apiVersion"]; !found || value == "" {
input["apiVersion"] = apiVersion
}
if value, found := input["kind"]; !found || value == "" {
input["kind"] = kind
}
opts := metav1.UpdateOptions{}
if err := decodeParams(apiOp, &opts); err != nil {