-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove all selected tags when using dump
The expected behaviour for `deck dump` when using `--select-tag` is the following: 1. selected tags information should be summarized at the top of the configuration file inside the `_info` structure 2. selected tags must be removed from entity-level tags Right now decK doesn't perform (2) consistently, stripping out selected tags from some entities, but not from some others. For example: ``` $ deck dump --select-tag test-tag --yes $ cat kong.yaml _format_version: "3.0" _info: defaults: {} select_tags: - test-tag services: - connect_timeout: 60000 enabled: true host: mockbin.org name: svc1 port: 80 protocol: http read_timeout: 60000 retries: 5 routes: - https_redirect_status_code: 301 name: r1 path_handling: v0 paths: - /r1 preserve_host: false protocols: - http - https regex_priority: 0 request_buffering: true response_buffering: true strip_path: true tags: - another-test-tag tags: - test-tag write_timeout: 60000 ``` Here, `test-tag` is correctly stripped out from the route entity, which now has only the `another-test-tag` tag, but the `test-tag` is still included in the service entity. This PR makes sure that selected tags are removed from all entities, so that this information will only be included in the `_info` structure.
- Loading branch information
Showing
5 changed files
with
676 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kong/go-kong/kong" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_Dump_SelectTags(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
stateFile string | ||
expectedFile string | ||
}{ | ||
{ | ||
name: "dump with select-tags", | ||
stateFile: "testdata/dump/001-entities-with-tags/kong.yaml", | ||
expectedFile: "testdata/dump/001-entities-with-tags/expected.yaml", | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
kong.RunWhenKong(t, ">=3.0.0") | ||
teardown := setup(t) | ||
defer teardown(t) | ||
|
||
assert.NoError(t, sync(tc.stateFile)) | ||
|
||
output, err := dump( | ||
"--select-tag", "managed-by-deck", | ||
"--select-tag", "org-unit-42", | ||
"-o", "-", | ||
) | ||
assert.NoError(t, err) | ||
|
||
expected, err := readFile(tc.expectedFile) | ||
assert.NoError(t, err) | ||
assert.Equal(t, output, expected) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.