Skip to content

Commit 976d655

Browse files
committed
combine remove and remove with value
1 parent 66e3b5f commit 976d655

File tree

8 files changed

+18
-29
lines changed

8 files changed

+18
-29
lines changed

pkg/resource/api_key/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func updateStageKeyPatches(patchSet *patch.Set, latest, desired []*svcapitypes.S
9696
key := fmt.Sprintf("%s/%s", *sk.RestAPIID, *sk.StageName)
9797
if !desiredMap[key] {
9898
encodedKey := strings.Replace(key, "/", "~1", -1)
99-
patchSet.Remove(fmt.Sprintf("/stages/%s", encodedKey))
99+
patchSet.Remove(fmt.Sprintf("/stages/%s", encodedKey), nil)
100100
}
101101
}
102102
}

pkg/resource/api_method_response/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func updateMethodResponseInput(desired, latest *resource, input *svcsdk.UpdateMe
3636
// Handle boolean map patching
3737
for k := range latestSpec.ResponseParameters {
3838
if _, ok := desiredSpec.ResponseParameters[k]; !ok {
39-
patchSet.Remove(fmt.Sprintf("/responseParameters/%s", patchKeyEncoder.Replace(k)))
39+
patchSet.Remove(fmt.Sprintf("/responseParameters/%s", patchKeyEncoder.Replace(k)), nil)
4040
}
4141
}
4242
for k, v := range desiredSpec.ResponseParameters {

pkg/resource/authorizer/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func updateProviderARNsPatches(
101101
for arn := range latestSet {
102102
if !desiredSet[arn] {
103103
// Use RemoveWithValue to generate: op=remove, path=/providerARNs, value=arn
104-
patchSet.RemoveWithValue("/providerARNs", aws.String(arn))
104+
patchSet.Remove("/providerARNs", aws.String(arn))
105105
}
106106
}
107107

pkg/resource/stage/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func updateCanarySettings(delta *compare.Delta, desiredSpec, latestSpec svcapity
7878
const rootKey = "/canarySettings"
7979
canary := desiredSpec.CanarySettings
8080
if canary == nil {
81-
patchSet.Remove(rootKey)
81+
patchSet.Remove(rootKey, nil)
8282
return
8383
}
8484

pkg/util/patch/patch.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,17 @@ func (p *Set) Add(path string, desiredVal *string) {
8787
}
8888

8989
// Remove adds a patch operation to this set for removing the specified path.
90-
func (p *Set) Remove(path string) {
91-
p.patchOps = append(p.patchOps, &apigatewaytypes.PatchOperation{
90+
// If valueToRemove is provided (not nil), it adds the value to the operation,
91+
// generating op=remove, path=<path>, value=<valueToRemove>.
92+
func (p *Set) Remove(path string, valueToRemove *string) {
93+
op := &apigatewaytypes.PatchOperation{
9294
Op: apigatewaytypes.OpRemove,
9395
Path: aws.String(path),
94-
})
95-
}
96-
97-
// RemoveWithValue adds a patch operation to this set for removing a specific value
98-
// from a list identified by the path.
99-
// This generates op=remove, path=<path>, value=<valueToRemove>.
100-
// Useful for APIs like API Gateway UpdateAuthorizer for providerARNs.
101-
func (p *Set) RemoveWithValue(path string, valueToRemove *string) {
102-
p.patchOps = append(p.patchOps, &apigatewaytypes.PatchOperation{
103-
Op: apigatewaytypes.OpRemove,
104-
Path: aws.String(path),
105-
Value: valueToRemove,
106-
})
96+
}
97+
if valueToRemove != nil {
98+
op.Value = valueToRemove
99+
}
100+
p.patchOps = append(p.patchOps, op)
107101
}
108102

109103
// GetPatchOperations returns the patch operations applied to this set.

pkg/util/patch/patch_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestPatchOperations(t *testing.T) {
3030
"k1": aws.String("v1"),
3131
"k3": aws.String("v3"),
3232
}, false)
33-
patchSet.Remove("/removed")
33+
patchSet.Remove("/removed", nil)
3434
},
3535
expectedPatchOps: []apigatewaytypes.PatchOperation{
3636
{
@@ -84,7 +84,7 @@ func TestPatchOperations(t *testing.T) {
8484
"k1~": aws.String("v1~/"),
8585
"k3~/": aws.String("v3~/"),
8686
}, false)
87-
patchSet.Remove("/removed")
87+
patchSet.Remove("/removed", nil)
8888
},
8989
expectedPatchOps: []apigatewaytypes.PatchOperation{
9090
{
@@ -138,7 +138,7 @@ func TestPatchOperations(t *testing.T) {
138138
"k1": aws.String("v1"),
139139
"k3": aws.String("v3"),
140140
}, true)
141-
patchSet.Remove("/removed")
141+
patchSet.Remove("/removed", nil)
142142
},
143143
expectedPatchOps: []apigatewaytypes.PatchOperation{
144144
{

test/e2e/conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,4 @@ def k8s_client():
4242

4343
@pytest.fixture(scope='module')
4444
def apigateway_client():
45-
return boto3.client('apigateway')
46-
47-
@pytest.fixture(scope='module')
48-
def cognito_client():
49-
return boto3.client('cognito-idp')
45+
return boto3.client('apigateway')

test/e2e/service_bootstrap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# not use this file except in compliance with the License. A copy of the
55
# License is located at
66
#
7-
# http://aws.amazon.com/apache2.0/
7+
# http://aws.amazon.com/apache2.0/
88
#
99
# or in the "license" file accompanying this file. This file is distributed
1010
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
@@ -13,7 +13,6 @@
1313
"""Bootstraps the resources required to run the API Gateway integration tests.
1414
"""
1515
import logging
16-
import os
1716

1817
from acktest.bootstrapping import Resources, BootstrapFailureException
1918

0 commit comments

Comments
 (0)