Skip to content

Commit

Permalink
Adding Group, Version, Kind in Update proxy_store.go (#270)
Browse files Browse the repository at this point in the history
* adding gvk completion to update method in proxy_store
  • Loading branch information
gehrkefc authored Sep 13, 2024
1 parent f02f3f9 commit 99e479b
Show file tree
Hide file tree
Showing 5 changed files with 726 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pkg/stores/partition/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package partition

import (
"context"
"errors"
"fmt"
"os"
"reflect"
Expand Down Expand Up @@ -389,7 +390,7 @@ func ToAPIEvent(apiOp *types.APIRequest, schema *types.APISchema, event watch.Ev

if event.Type == watch.Error {
status, _ := event.Object.(*metav1.Status)
apiEvent.Error = fmt.Errorf(status.Message)
apiEvent.Error = errors.New(status.Message)
return apiEvent
}

Expand Down
10 changes: 7 additions & 3 deletions pkg/stores/proxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ import (
)

const (
watchTimeoutEnv = "CATTLE_WATCH_TIMEOUT_SECONDS"
errNamespaceRequired = "metadata.namespace is required"
watchTimeoutEnv = "CATTLE_WATCH_TIMEOUT_SECONDS"
errNamespaceRequired = "metadata.namespace is required"
errResourceVersionRequired = "metadata.resourceVersion is required for update"
)

var (
Expand Down Expand Up @@ -515,9 +516,12 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params

resourceVersion := input.String("metadata", "resourceVersion")
if resourceVersion == "" {
return nil, nil, fmt.Errorf("metadata.resourceVersion is required for update")
return nil, nil, errors.New(errResourceVersionRequired)
}

gvk := attributes.GVK(schema)
input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind()

opts := metav1.UpdateOptions{}
if err := decodeParams(apiOp, &opts); err != nil {
return nil, nil, err
Expand Down
Loading

0 comments on commit 99e479b

Please sign in to comment.