From 0fcf47917b26f32a0ab8a5f54a9d456c6777d186 Mon Sep 17 00:00:00 2001 From: "Felipe C. Gehrke" Date: Fri, 30 Aug 2024 19:11:50 -0300 Subject: [PATCH 1/8] adding gvk completion to update method in proxy_store --- pkg/stores/proxy/proxy_store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index d998a071..22c756a6 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -505,6 +505,9 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params return nil, nil, fmt.Errorf("metadata.resourceVersion is required for update") } + gvk := attributes.GVK(schema) + input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind() + opts := metav1.UpdateOptions{} if err := decodeParams(apiOp, &opts); err != nil { return nil, nil, err From 93489619a8da78946e406ca7a1f0c0086c9c5ee7 Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Mon, 2 Sep 2024 23:46:29 -0300 Subject: [PATCH 2/8] added values overwrite check --- pkg/stores/proxy/proxy_store.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index 22c756a6..90261901 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -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 { From cc1b580a18afb2547dd6286dd0ecea66a8df3ff1 Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Wed, 11 Sep 2024 21:32:02 -0300 Subject: [PATCH 3/8] added TestUpdate --- pkg/stores/proxy/proxy_store.go | 7 +- pkg/stores/proxy/proxy_store_test.go | 349 +++++++++++++++++++++++- pkg/stores/sqlproxy/proxy_store.go | 28 +- pkg/stores/sqlproxy/proxy_store_test.go | 344 +++++++++++++++++++++++ 4 files changed, 719 insertions(+), 9 deletions(-) diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index 487f5dca..b2bb31b7 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -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 ( @@ -523,7 +524,7 @@ 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, fmt.Errorf(errResourceVersionRequired) } gvk := attributes.GVK(schema) diff --git a/pkg/stores/proxy/proxy_store_test.go b/pkg/stores/proxy/proxy_store_test.go index af90ef00..5fe97dfb 100644 --- a/pkg/stores/proxy/proxy_store_test.go +++ b/pkg/stores/proxy/proxy_store_test.go @@ -1,6 +1,7 @@ package proxy import ( + "fmt" "net/http" "net/url" "strings" @@ -343,7 +344,7 @@ func TestCreate(t *testing.T) { }, }, { - name: "missing namespace in the params / should copy from apiOp", + name: "missing namespace in the params (should copy from apiOp)", input: input{ apiOp: &types.APIRequest{ Schema: &types.APISchema{ @@ -466,7 +467,7 @@ func TestCreate(t *testing.T) { for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { testClientFactory, err := client.NewFactory(&rest.Config{}, false) - assert.Nil(t, err) + assert.NoError(t, err) fakeClient := fake.NewSimpleDynamicClient(runtime.NewScheme()) @@ -488,3 +489,347 @@ func TestCreate(t *testing.T) { }) } } + +func TestUpdate(t *testing.T) { + type input struct { + apiOp *types.APIRequest + schema *types.APISchema + params types.APIObject + id string + } + + type expected struct { + value *unstructured.Unstructured + warning []types.Warning + err error + } + + sampleCreateInput := input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v1", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "kind": "Secret", + "apiVersion": "v1", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + } + + testCases := []struct { + name string + updateCallbackFunc clientgotesting.ReactionFunc + createInput *input + updateInput input + expected expected + }{ + { + name: "update - usual request", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing resource version", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v1", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + }, + }, + }, + }, + expected: expected{ + value: nil, + warning: nil, + err: fmt.Errorf(errResourceVersionRequired), + }, + }, + { + name: "update - missing apiVersion (should copy from schema)", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing kind (should copy from schema)", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - error request", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return true, nil, apierrors.NewUnauthorized("sample reason") + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: nil, + warning: nil, + err: apierrors.NewUnauthorized("sample reason"), + }, + }, + } + + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + testClientFactory, err := client.NewFactory(&rest.Config{}, false) + assert.NoError(t, err) + + fakeClient := fake.NewSimpleDynamicClient(runtime.NewScheme()) + + if tt.updateCallbackFunc != nil { + fakeClient.PrependReactor("update", "*", tt.updateCallbackFunc) + } + + testStore := Store{ + clientGetter: &testFactory{Factory: testClientFactory, + fakeClient: fakeClient, + }, + } + + // Creating the object first, so we can update it later (this function is not the SUT) + if tt.createInput != nil { + _, _, err = testStore.Create(tt.createInput.apiOp, tt.createInput.schema, tt.createInput.params) + assert.NoError(t, err) + } + + value, warning, err := testStore.Update(tt.updateInput.apiOp, tt.updateInput.schema, tt.updateInput.params, tt.updateInput.id) + + assert.Equal(t, tt.expected.value, value) + assert.Equal(t, tt.expected.warning, warning) + assert.Equal(t, tt.expected.err, err) + }) + } +} diff --git a/pkg/stores/sqlproxy/proxy_store.go b/pkg/stores/sqlproxy/proxy_store.go index c975973e..62132e45 100644 --- a/pkg/stores/sqlproxy/proxy_store.go +++ b/pkg/stores/sqlproxy/proxy_store.go @@ -50,8 +50,9 @@ import ( ) const ( - watchTimeoutEnv = "CATTLE_WATCH_TIMEOUT_SECONDS" - errNamespaceRequired = "metadata.namespace or apiOp.namespace are required" + watchTimeoutEnv = "CATTLE_WATCH_TIMEOUT_SECONDS" + errNamespaceRequired = "metadata.namespace or apiOp.namespace are required" + errResourceVersionRequired = "metadata.resourceVersion is required for update" ) var ( @@ -528,7 +529,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, namespace, &buffer)) @@ -598,7 +607,18 @@ 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, fmt.Errorf(errResourceVersionRequired) + } + + gvk := attributes.GVK(schema) + 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{} diff --git a/pkg/stores/sqlproxy/proxy_store_test.go b/pkg/stores/sqlproxy/proxy_store_test.go index ec1cb501..336d2f8e 100644 --- a/pkg/stores/sqlproxy/proxy_store_test.go +++ b/pkg/stores/sqlproxy/proxy_store_test.go @@ -1104,3 +1104,347 @@ func TestCreate(t *testing.T) { }) } } + +func TestUpdate(t *testing.T) { + type input struct { + apiOp *types.APIRequest + schema *types.APISchema + params types.APIObject + id string + } + + type expected struct { + value *unstructured.Unstructured + warning []types.Warning + err error + } + + sampleCreateInput := input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v1", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "kind": "Secret", + "apiVersion": "v1", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + } + + testCases := []struct { + name string + updateCallbackFunc clientgotesting.ReactionFunc + createInput *input + updateInput input + expected expected + }{ + { + name: "update - usual request", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing resource version", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v1", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + }, + }, + }, + }, + expected: expected{ + value: nil, + warning: nil, + err: fmt.Errorf(errResourceVersionRequired), + }, + }, + { + name: "update - missing apiVersion (should copy from schema)", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing kind (should copy from schema)", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - error request", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return true, nil, apierrors.NewUnauthorized("sample reason") + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v2", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: nil, + warning: nil, + err: apierrors.NewUnauthorized("sample reason"), + }, + }, + } + + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + testClientFactory, err := client.NewFactory(&rest.Config{}, false) + assert.NoError(t, err) + + fakeClient := fake.NewSimpleDynamicClient(runtime.NewScheme()) + + if tt.updateCallbackFunc != nil { + fakeClient.PrependReactor("update", "*", tt.updateCallbackFunc) + } + + testStore := Store{ + clientGetter: &testFactory{Factory: testClientFactory, + fakeClient: fakeClient, + }, + } + + // Creating the object first, so we can update it later (this function is not the SUT) + if tt.createInput != nil { + _, _, err = testStore.Create(tt.createInput.apiOp, tt.createInput.schema, tt.createInput.params) + assert.NoError(t, err) + } + + value, warning, err := testStore.Update(tt.updateInput.apiOp, tt.updateInput.schema, tt.updateInput.params, tt.updateInput.id) + + assert.Equal(t, tt.expected.value, value) + assert.Equal(t, tt.expected.warning, warning) + assert.Equal(t, tt.expected.err, err) + }) + } +} From e20157f2d932d45c75f11471ff00ea49047df10e Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Thu, 12 Sep 2024 14:23:53 -0300 Subject: [PATCH 4/8] chaging it replace apiVersion and kind from input to schema --- pkg/stores/proxy/proxy_store.go | 20 +---- pkg/stores/proxy/proxy_store_test.go | 113 +----------------------- pkg/stores/sqlproxy/proxy_store.go | 20 +---- pkg/stores/sqlproxy/proxy_store_test.go | 113 +----------------------- 4 files changed, 12 insertions(+), 254 deletions(-) diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index b2bb31b7..da275e75 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -446,15 +446,7 @@ func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params } gvk := attributes.GVK(schema) - apiVersion, kind := gvk.ToAPIVersionAndKind() - - if value, found := input["apiVersion"]; !found || value == "" { - input["apiVersion"] = apiVersion - } - - if value, found := input["kind"]; !found || value == "" { - input["kind"] = kind - } + input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind() buffer := WarningBuffer{} k8sClient, err := metricsStore.Wrap(s.clientGetter.TableClient(apiOp, schema, namespace, &buffer)) @@ -528,15 +520,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params } gvk := attributes.GVK(schema) - apiVersion, kind := gvk.ToAPIVersionAndKind() - - if value, found := input["apiVersion"]; !found || value == "" { - input["apiVersion"] = apiVersion - } - - if value, found := input["kind"]; !found || value == "" { - input["kind"] = kind - } + input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind() opts := metav1.UpdateOptions{} if err := decodeParams(apiOp, &opts); err != nil { diff --git a/pkg/stores/proxy/proxy_store_test.go b/pkg/stores/proxy/proxy_store_test.go index 5fe97dfb..47fe2b37 100644 --- a/pkg/stores/proxy/proxy_store_test.go +++ b/pkg/stores/proxy/proxy_store_test.go @@ -521,6 +521,7 @@ func TestUpdate(t *testing.T) { Schema: &schemas.Schema{ ID: "testing", Attributes: map[string]interface{}{ + "kind": "Secret", "version": "v1", "namespaced": true, }, @@ -570,13 +571,15 @@ func TestUpdate(t *testing.T) { Schema: &schemas.Schema{ ID: "testing", Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", "namespaced": true, }, }, }, params: types.APIObject{ Object: map[string]interface{}{ - "apiVersion": "v2", + "apiVersion": "v1", "kind": "Secret", "metadata": map[string]interface{}{ "name": "testing-secret", @@ -646,114 +649,6 @@ func TestUpdate(t *testing.T) { err: fmt.Errorf(errResourceVersionRequired), }, }, - { - name: "update - missing apiVersion (should copy from schema)", - updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return false, ret, nil - }, - createInput: &sampleCreateInput, - updateInput: input{ - apiOp: &types.APIRequest{ - Request: &http.Request{ - URL: &url.URL{}, - Method: http.MethodPut, - }, - Schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - }, - }, - Method: http.MethodPut, - }, - - schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - Attributes: map[string]interface{}{ - "version": "v2", - "namespaced": true, - }, - }, - }, - params: types.APIObject{ - Object: map[string]interface{}{ - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }, - }, - }, - expected: expected{ - value: &unstructured.Unstructured{Object: map[string]interface{}{ - "apiVersion": "v2", - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }}, - warning: []types.Warning{}, - err: nil, - }, - }, - { - name: "update - missing kind (should copy from schema)", - updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return false, ret, nil - }, - createInput: &sampleCreateInput, - updateInput: input{ - apiOp: &types.APIRequest{ - Request: &http.Request{ - URL: &url.URL{}, - Method: http.MethodPut, - }, - Schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - }, - }, - Method: http.MethodPut, - }, - - schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - Attributes: map[string]interface{}{ - "kind": "Secret", - "namespaced": true, - }, - }, - }, - params: types.APIObject{ - Object: map[string]interface{}{ - "apiVersion": "v2", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }, - }, - }, - expected: expected{ - value: &unstructured.Unstructured{Object: map[string]interface{}{ - "apiVersion": "v2", - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }}, - warning: []types.Warning{}, - err: nil, - }, - }, { name: "update - error request", updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { diff --git a/pkg/stores/sqlproxy/proxy_store.go b/pkg/stores/sqlproxy/proxy_store.go index 62132e45..64f3fd2c 100644 --- a/pkg/stores/sqlproxy/proxy_store.go +++ b/pkg/stores/sqlproxy/proxy_store.go @@ -529,15 +529,7 @@ func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params } gvk := attributes.GVK(schema) - apiVersion, kind := gvk.ToAPIVersionAndKind() - - if value, found := input["apiVersion"]; !found || value == "" { - input["apiVersion"] = apiVersion - } - - if value, found := input["kind"]; !found || value == "" { - input["kind"] = kind - } + input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind() buffer := WarningBuffer{} k8sClient, err := metricsStore.Wrap(s.clientGetter.TableClient(apiOp, schema, namespace, &buffer)) @@ -611,15 +603,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params } gvk := attributes.GVK(schema) - apiVersion, kind := gvk.ToAPIVersionAndKind() - - if value, found := input["apiVersion"]; !found || value == "" { - input["apiVersion"] = apiVersion - } - - if value, found := input["kind"]; !found || value == "" { - input["kind"] = kind - } + input["apiVersion"], input["kind"] = gvk.ToAPIVersionAndKind() opts := metav1.UpdateOptions{} if err := decodeParams(apiOp, &opts); err != nil { diff --git a/pkg/stores/sqlproxy/proxy_store_test.go b/pkg/stores/sqlproxy/proxy_store_test.go index 336d2f8e..8e61deca 100644 --- a/pkg/stores/sqlproxy/proxy_store_test.go +++ b/pkg/stores/sqlproxy/proxy_store_test.go @@ -1136,6 +1136,7 @@ func TestUpdate(t *testing.T) { Schema: &schemas.Schema{ ID: "testing", Attributes: map[string]interface{}{ + "kind": "Secret", "version": "v1", "namespaced": true, }, @@ -1185,13 +1186,15 @@ func TestUpdate(t *testing.T) { Schema: &schemas.Schema{ ID: "testing", Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", "namespaced": true, }, }, }, params: types.APIObject{ Object: map[string]interface{}{ - "apiVersion": "v2", + "apiVersion": "v1", "kind": "Secret", "metadata": map[string]interface{}{ "name": "testing-secret", @@ -1261,114 +1264,6 @@ func TestUpdate(t *testing.T) { err: fmt.Errorf(errResourceVersionRequired), }, }, - { - name: "update - missing apiVersion (should copy from schema)", - updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return false, ret, nil - }, - createInput: &sampleCreateInput, - updateInput: input{ - apiOp: &types.APIRequest{ - Request: &http.Request{ - URL: &url.URL{}, - Method: http.MethodPut, - }, - Schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - }, - }, - Method: http.MethodPut, - }, - - schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - Attributes: map[string]interface{}{ - "version": "v2", - "namespaced": true, - }, - }, - }, - params: types.APIObject{ - Object: map[string]interface{}{ - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }, - }, - }, - expected: expected{ - value: &unstructured.Unstructured{Object: map[string]interface{}{ - "apiVersion": "v2", - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }}, - warning: []types.Warning{}, - err: nil, - }, - }, - { - name: "update - missing kind (should copy from schema)", - updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return false, ret, nil - }, - createInput: &sampleCreateInput, - updateInput: input{ - apiOp: &types.APIRequest{ - Request: &http.Request{ - URL: &url.URL{}, - Method: http.MethodPut, - }, - Schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - }, - }, - Method: http.MethodPut, - }, - - schema: &types.APISchema{ - Schema: &schemas.Schema{ - ID: "testing", - Attributes: map[string]interface{}{ - "kind": "Secret", - "namespaced": true, - }, - }, - }, - params: types.APIObject{ - Object: map[string]interface{}{ - "apiVersion": "v2", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }, - }, - }, - expected: expected{ - value: &unstructured.Unstructured{Object: map[string]interface{}{ - "apiVersion": "v2", - "kind": "Secret", - "metadata": map[string]interface{}{ - "name": "testing-secret", - "namespace": "testing-ns", - "resourceVersion": "1", - }, - }}, - warning: []types.Warning{}, - err: nil, - }, - }, { name: "update - error request", updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { From c886752a277fb70cbb3c09ec2bc1095be2d1cf7e Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Thu, 12 Sep 2024 14:57:24 -0300 Subject: [PATCH 5/8] updated tests --- pkg/stores/proxy/proxy_store_test.go | 116 +++++++++++++++++++++++- pkg/stores/sqlproxy/proxy_store_test.go | 116 +++++++++++++++++++++++- 2 files changed, 226 insertions(+), 6 deletions(-) diff --git a/pkg/stores/proxy/proxy_store_test.go b/pkg/stores/proxy/proxy_store_test.go index 47fe2b37..6d41c8ae 100644 --- a/pkg/stores/proxy/proxy_store_test.go +++ b/pkg/stores/proxy/proxy_store_test.go @@ -508,14 +508,14 @@ func TestUpdate(t *testing.T) { apiOp: &types.APIRequest{ Request: &http.Request{ URL: &url.URL{}, - Method: http.MethodPut, + Method: http.MethodPost, }, Schema: &types.APISchema{ Schema: &schemas.Schema{ ID: "testing", }, }, - Method: http.MethodPut, + Method: http.MethodPost, }, schema: &types.APISchema{ Schema: &schemas.Schema{ @@ -579,7 +579,7 @@ func TestUpdate(t *testing.T) { }, params: types.APIObject{ Object: map[string]interface{}{ - "apiVersion": "v1", + "apiVersion": "v2", "kind": "Secret", "metadata": map[string]interface{}{ "name": "testing-secret", @@ -603,6 +603,116 @@ func TestUpdate(t *testing.T) { err: nil, }, }, + { + name: "update - different apiVersion and kind (params and schema) - should copy from schema", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "ConfigMap", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing apiVersion and kind in params - should copy from schema", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPost, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPost, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, { name: "update - missing resource version", updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { diff --git a/pkg/stores/sqlproxy/proxy_store_test.go b/pkg/stores/sqlproxy/proxy_store_test.go index 8e61deca..96173c7d 100644 --- a/pkg/stores/sqlproxy/proxy_store_test.go +++ b/pkg/stores/sqlproxy/proxy_store_test.go @@ -1123,14 +1123,14 @@ func TestUpdate(t *testing.T) { apiOp: &types.APIRequest{ Request: &http.Request{ URL: &url.URL{}, - Method: http.MethodPut, + Method: http.MethodPost, }, Schema: &types.APISchema{ Schema: &schemas.Schema{ ID: "testing", }, }, - Method: http.MethodPut, + Method: http.MethodPost, }, schema: &types.APISchema{ Schema: &schemas.Schema{ @@ -1194,7 +1194,7 @@ func TestUpdate(t *testing.T) { }, params: types.APIObject{ Object: map[string]interface{}{ - "apiVersion": "v1", + "apiVersion": "v2", "kind": "Secret", "metadata": map[string]interface{}{ "name": "testing-secret", @@ -1218,6 +1218,116 @@ func TestUpdate(t *testing.T) { err: nil, }, }, + { + name: "update - different apiVersion and kind (params and schema) - should copy from schema", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPut, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPut, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "ConfigMap", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, + { + name: "update - missing apiVersion and kind in params - should copy from schema", + updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + return false, ret, nil + }, + createInput: &sampleCreateInput, + updateInput: input{ + apiOp: &types.APIRequest{ + Request: &http.Request{ + URL: &url.URL{}, + Method: http.MethodPost, + }, + Schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + }, + }, + Method: http.MethodPost, + }, + + schema: &types.APISchema{ + Schema: &schemas.Schema{ + ID: "testing", + Attributes: map[string]interface{}{ + "version": "v2", + "kind": "Secret", + "namespaced": true, + }, + }, + }, + params: types.APIObject{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }, + }, + }, + expected: expected{ + value: &unstructured.Unstructured{Object: map[string]interface{}{ + "apiVersion": "v2", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": "testing-secret", + "namespace": "testing-ns", + "resourceVersion": "1", + }, + }}, + warning: []types.Warning{}, + err: nil, + }, + }, { name: "update - missing resource version", updateCallbackFunc: func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { From be0c0a3d5420bb11799dafa78259914f4aae124c Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Thu, 12 Sep 2024 15:24:56 -0300 Subject: [PATCH 6/8] addressing eric's comment --- pkg/stores/partition/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/stores/partition/store.go b/pkg/stores/partition/store.go index f90aabcd..b97193a3 100644 --- a/pkg/stores/partition/store.go +++ b/pkg/stores/partition/store.go @@ -389,7 +389,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 = fmt.Errorf("%s", status.Message) return apiEvent } From ed8bdb68e6ffb57d24338c9d17030cede373fbc9 Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Fri, 13 Sep 2024 11:42:50 -0300 Subject: [PATCH 7/8] addressing comments from eric #2 --- pkg/stores/partition/store.go | 3 ++- pkg/stores/proxy/proxy_store.go | 2 +- pkg/stores/proxy/proxy_store_test.go | 9 +++++++-- pkg/stores/sqlproxy/proxy_store.go | 2 +- pkg/stores/sqlproxy/proxy_store_test.go | 9 +++++++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pkg/stores/partition/store.go b/pkg/stores/partition/store.go index b97193a3..c018fc4b 100644 --- a/pkg/stores/partition/store.go +++ b/pkg/stores/partition/store.go @@ -4,6 +4,7 @@ package partition import ( "context" + "errors" "fmt" "os" "reflect" @@ -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("%s", status.Message) + apiEvent.Error = errors.New(status.Message) return apiEvent } diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index da275e75..7faf6aee 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -516,7 +516,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params resourceVersion := input.String("metadata", "resourceVersion") if resourceVersion == "" { - return nil, nil, fmt.Errorf(errResourceVersionRequired) + return nil, nil, errors.New(errResourceVersionRequired) } gvk := attributes.GVK(schema) diff --git a/pkg/stores/proxy/proxy_store_test.go b/pkg/stores/proxy/proxy_store_test.go index 6d41c8ae..b45ddafb 100644 --- a/pkg/stores/proxy/proxy_store_test.go +++ b/pkg/stores/proxy/proxy_store_test.go @@ -756,7 +756,7 @@ func TestUpdate(t *testing.T) { expected: expected{ value: nil, warning: nil, - err: fmt.Errorf(errResourceVersionRequired), + err: errors.New(errResourceVersionRequired), }, }, { @@ -834,7 +834,12 @@ func TestUpdate(t *testing.T) { assert.Equal(t, tt.expected.value, value) assert.Equal(t, tt.expected.warning, warning) - assert.Equal(t, tt.expected.err, err) + + if tt.expected.err != nil { + assert.Equal(t, tt.expected.err.Error(), err.Error()) + } else { + assert.NoError(t, err) + } }) } } diff --git a/pkg/stores/sqlproxy/proxy_store.go b/pkg/stores/sqlproxy/proxy_store.go index 64f3fd2c..d2ab50f6 100644 --- a/pkg/stores/sqlproxy/proxy_store.go +++ b/pkg/stores/sqlproxy/proxy_store.go @@ -599,7 +599,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params resourceVersion := input.String("metadata", "resourceVersion") if resourceVersion == "" { - return nil, nil, fmt.Errorf(errResourceVersionRequired) + return nil, nil, errors.New(errResourceVersionRequired) } gvk := attributes.GVK(schema) diff --git a/pkg/stores/sqlproxy/proxy_store_test.go b/pkg/stores/sqlproxy/proxy_store_test.go index 96173c7d..54f31f0d 100644 --- a/pkg/stores/sqlproxy/proxy_store_test.go +++ b/pkg/stores/sqlproxy/proxy_store_test.go @@ -1371,7 +1371,7 @@ func TestUpdate(t *testing.T) { expected: expected{ value: nil, warning: nil, - err: fmt.Errorf(errResourceVersionRequired), + err: errors.New(errResourceVersionRequired), }, }, { @@ -1449,7 +1449,12 @@ func TestUpdate(t *testing.T) { assert.Equal(t, tt.expected.value, value) assert.Equal(t, tt.expected.warning, warning) - assert.Equal(t, tt.expected.err, err) + + if tt.expected.err != nil { + assert.Equal(t, tt.expected.err.Error(), err.Error()) + } else { + assert.NoError(t, err) + } }) } } From a11254e5f53c51b1c70ece8b8752cb5868cafb00 Mon Sep 17 00:00:00 2001 From: gehrkefc Date: Fri, 13 Sep 2024 11:46:06 -0300 Subject: [PATCH 8/8] fix import --- pkg/stores/proxy/proxy_store_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/stores/proxy/proxy_store_test.go b/pkg/stores/proxy/proxy_store_test.go index b45ddafb..b1b488f9 100644 --- a/pkg/stores/proxy/proxy_store_test.go +++ b/pkg/stores/proxy/proxy_store_test.go @@ -1,7 +1,6 @@ package proxy import ( - "fmt" "net/http" "net/url" "strings"